diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 0000000000..6ba6ae82c8
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,18 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "cake.tool": {
+ "version": "0.35.0",
+ "commands": [
+ "dotnet-cake"
+ ]
+ },
+ "dotnet-format": {
+ "version": "3.1.37601",
+ "commands": [
+ "dotnet-format"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
index 0dd7ef8ed1..b5333ad8e7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,16 +12,183 @@ trim_trailing_whitespace = true
#PascalCase for public and protected members
dotnet_naming_style.pascalcase.capitalization = pascal_case
-dotnet_naming_symbols.public_members.applicable_accessibilities = public,internal,protected,protected_internal
-dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event,delegate
-dotnet_naming_rule.public_members_pascalcase.severity = suggestion
+dotnet_naming_symbols.public_members.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event
+dotnet_naming_rule.public_members_pascalcase.severity = error
dotnet_naming_rule.public_members_pascalcase.symbols = public_members
dotnet_naming_rule.public_members_pascalcase.style = pascalcase
#camelCase for private members
dotnet_naming_style.camelcase.capitalization = camel_case
+
dotnet_naming_symbols.private_members.applicable_accessibilities = private
-dotnet_naming_symbols.private_members.applicable_kinds = property,method,field,event,delegate
-dotnet_naming_rule.private_members_camelcase.severity = suggestion
+dotnet_naming_symbols.private_members.applicable_kinds = property,method,field,event
+dotnet_naming_rule.private_members_camelcase.severity = warning
dotnet_naming_rule.private_members_camelcase.symbols = private_members
-dotnet_naming_rule.private_members_camelcase.style = camelcase
\ No newline at end of file
+dotnet_naming_rule.private_members_camelcase.style = camelcase
+
+dotnet_naming_symbols.local_function.applicable_kinds = local_function
+dotnet_naming_rule.local_function_camelcase.severity = warning
+dotnet_naming_rule.local_function_camelcase.symbols = local_function
+dotnet_naming_rule.local_function_camelcase.style = camelcase
+
+#all_lower for private and local constants/static readonlys
+dotnet_naming_style.all_lower.capitalization = all_lower
+dotnet_naming_style.all_lower.word_separator = _
+
+dotnet_naming_symbols.private_constants.applicable_accessibilities = private
+dotnet_naming_symbols.private_constants.required_modifiers = const
+dotnet_naming_symbols.private_constants.applicable_kinds = field
+dotnet_naming_rule.private_const_all_lower.severity = warning
+dotnet_naming_rule.private_const_all_lower.symbols = private_constants
+dotnet_naming_rule.private_const_all_lower.style = all_lower
+
+dotnet_naming_symbols.private_static_readonly.applicable_accessibilities = private
+dotnet_naming_symbols.private_static_readonly.required_modifiers = static,readonly
+dotnet_naming_symbols.private_static_readonly.applicable_kinds = field
+dotnet_naming_rule.private_static_readonly_all_lower.severity = warning
+dotnet_naming_rule.private_static_readonly_all_lower.symbols = private_static_readonly
+dotnet_naming_rule.private_static_readonly_all_lower.style = all_lower
+
+dotnet_naming_symbols.local_constants.applicable_kinds = local
+dotnet_naming_symbols.local_constants.required_modifiers = const
+dotnet_naming_rule.local_const_all_lower.severity = warning
+dotnet_naming_rule.local_const_all_lower.symbols = local_constants
+dotnet_naming_rule.local_const_all_lower.style = all_lower
+
+#ALL_UPPER for non private constants/static readonlys
+dotnet_naming_style.all_upper.capitalization = all_upper
+dotnet_naming_style.all_upper.word_separator = _
+
+dotnet_naming_symbols.public_constants.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.public_constants.required_modifiers = const
+dotnet_naming_symbols.public_constants.applicable_kinds = field
+dotnet_naming_rule.public_const_all_upper.severity = warning
+dotnet_naming_rule.public_const_all_upper.symbols = public_constants
+dotnet_naming_rule.public_const_all_upper.style = all_upper
+
+dotnet_naming_symbols.public_static_readonly.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.public_static_readonly.required_modifiers = static,readonly
+dotnet_naming_symbols.public_static_readonly.applicable_kinds = field
+dotnet_naming_rule.public_static_readonly_all_upper.severity = warning
+dotnet_naming_rule.public_static_readonly_all_upper.symbols = public_static_readonly
+dotnet_naming_rule.public_static_readonly_all_upper.style = all_upper
+
+#Roslyn formating options
+
+#Formatting - indentation options
+csharp_indent_case_contents = true
+csharp_indent_case_contents_when_block = false
+csharp_indent_labels = one_less_than_current
+csharp_indent_switch_labels = true
+
+#Formatting - new line options
+csharp_new_line_before_catch = true
+csharp_new_line_before_else = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_open_brace = all
+#csharp_new_line_before_members_in_anonymous_types = true
+#csharp_new_line_before_members_in_object_initializers = true # Currently no effect in VS/dotnet format (16.4), and makes Rider confusing
+csharp_new_line_between_query_expression_clauses = true
+
+#Formatting - organize using options
+dotnet_sort_system_directives_first = true
+
+#Formatting - spacing options
+csharp_space_after_cast = false
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+
+#Formatting - wrapping options
+csharp_preserve_single_line_blocks = true
+csharp_preserve_single_line_statements = true
+
+#Roslyn language styles
+
+#Style - this. qualification
+dotnet_style_qualification_for_field = false:warning
+dotnet_style_qualification_for_property = false:warning
+dotnet_style_qualification_for_method = false:warning
+dotnet_style_qualification_for_event = false:warning
+
+#Style - type names
+dotnet_style_predefined_type_for_locals_parameters_members = true:warning
+dotnet_style_predefined_type_for_member_access = true:warning
+csharp_style_var_when_type_is_apparent = true:none
+csharp_style_var_for_built_in_types = true:none
+csharp_style_var_elsewhere = true:silent
+
+#Style - modifiers
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
+csharp_preferred_modifier_order = public,private,protected,internal,new,abstract,virtual,sealed,override,static,readonly,extern,unsafe,volatile,async:warning
+
+#Style - parentheses
+# Skipped because roslyn cannot separate +-*/ with << >>
+
+#Style - expression bodies
+csharp_style_expression_bodied_accessors = true:warning
+csharp_style_expression_bodied_constructors = false:none
+csharp_style_expression_bodied_indexers = true:warning
+csharp_style_expression_bodied_methods = true:silent
+csharp_style_expression_bodied_operators = true:warning
+csharp_style_expression_bodied_properties = true:warning
+csharp_style_expression_bodied_local_functions = true:silent
+
+#Style - expression preferences
+dotnet_style_object_initializer = true:warning
+dotnet_style_collection_initializer = true:warning
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
+dotnet_style_prefer_auto_properties = true:warning
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+dotnet_style_prefer_compound_assignment = true:warning
+
+#Style - null/type checks
+dotnet_style_coalesce_expression = true:warning
+dotnet_style_null_propagation = true:warning
+csharp_style_pattern_matching_over_is_with_cast_check = true:warning
+csharp_style_pattern_matching_over_as_with_null_check = true:warning
+csharp_style_throw_expression = true:silent
+csharp_style_conditional_delegate_call = true:warning
+
+#Style - unused
+dotnet_style_readonly_field = true:silent
+dotnet_code_quality_unused_parameters = non_public:silent
+csharp_style_unused_value_expression_statement_preference = discard_variable:silent
+csharp_style_unused_value_assignment_preference = discard_variable:warning
+
+#Style - variable declaration
+csharp_style_inlined_variable_declaration = true:warning
+csharp_style_deconstructed_variable_declaration = true:warning
+
+#Style - other C# 7.x features
+dotnet_style_prefer_inferred_tuple_names = true:warning
+csharp_prefer_simple_default_expression = true:warning
+csharp_style_pattern_local_over_anonymous_function = true:warning
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
+
+#Style - C# 8 features
+csharp_prefer_static_local_function = true:warning
+csharp_prefer_simple_using_statement = true:silent
+csharp_style_prefer_index_operator = false:none
+csharp_style_prefer_range_operator = false:none
+csharp_style_prefer_switch_expression = false:none
+
+#Supressing roslyn built-in analyzers
+# Suppress: EC112
+
+#Private method is unused
+dotnet_diagnostic.IDE0051.severity = silent
+#Private member is unused
+dotnet_diagnostic.IDE0052.severity = silent
+
+#Rules for disposable
+dotnet_diagnostic.IDE0067.severity = none
+dotnet_diagnostic.IDE0068.severity = none
+dotnet_diagnostic.IDE0069.severity = none
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/00-mobile-issues.md b/.github/ISSUE_TEMPLATE/00-mobile-issues.md
new file mode 100644
index 0000000000..f171e80b8b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/00-mobile-issues.md
@@ -0,0 +1,8 @@
+---
+name: Mobile Report
+about: ⚠ Due to current development priorities we are not accepting mobile reports at this time (unless you're willing to fix them yourself!)
+---
+
+⚠ **PLEASE READ** ⚠: Due to prioritising finishing the client for desktop first we are not accepting reports related to mobile platforms for the time being, unless you're willing to fix them.
+If you'd like to report a problem or suggest a feature and then work on it, feel free to open an issue and highlight that you'd like to address it yourself in the issue body; mobile pull requests are also welcome.
+Otherwise, please check back in the future when the focus of development shifts towards mobile!
diff --git a/.github/ISSUE_TEMPLATE/bug-issues.md b/.github/ISSUE_TEMPLATE/01-bug-issues.md
similarity index 100%
rename from .github/ISSUE_TEMPLATE/bug-issues.md
rename to .github/ISSUE_TEMPLATE/01-bug-issues.md
diff --git a/.github/ISSUE_TEMPLATE/crash-issues.md b/.github/ISSUE_TEMPLATE/02-crash-issues.md
similarity index 100%
rename from .github/ISSUE_TEMPLATE/crash-issues.md
rename to .github/ISSUE_TEMPLATE/02-crash-issues.md
diff --git a/.github/ISSUE_TEMPLATE/feature-request-issues.md b/.github/ISSUE_TEMPLATE/03-feature-request-issues.md
similarity index 100%
rename from .github/ISSUE_TEMPLATE/feature-request-issues.md
rename to .github/ISSUE_TEMPLATE/03-feature-request-issues.md
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000..69baeee60c
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
+blank_issues_enabled: false
+contact_links:
+ - name: osu!stable issues
+ url: https://github.com/ppy/osu-stable-issues
+ about: For issues regarding osu!stable (not osu!lazer), open them here.
diff --git a/.github/ISSUE_TEMPLATE/missing-for-live-issues.md b/.github/ISSUE_TEMPLATE/missing-for-live-issues.md
deleted file mode 100644
index 5822da9c65..0000000000
--- a/.github/ISSUE_TEMPLATE/missing-for-live-issues.md
+++ /dev/null
@@ -1,7 +0,0 @@
----
-name: Missing for Live
-about: Features which are available in osu!stable but not yet in osu!lazer.
----
-**Describe the missing feature:**
-
-**Proposal designs of the feature:**
diff --git a/.gitignore b/.gitignore
index e60058ab35..e6b5db5904 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,14 +10,8 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
-### Cake ###
-tools/**
-build/tools/**
-
-fastlane/report.xml
-
# Build results
-bin/[Dd]ebug/
+[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
@@ -104,7 +98,6 @@ $tf/
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
-inspectcode
# JustCode is a .NET coding add-in
.JustCode
@@ -254,20 +247,87 @@ paket-files/
# FAKE - F# Make
.fake/
-# JetBrains Rider
-.idea/.idea.osu/.idea/*.xml
-.idea/.idea.osu/.idea/codeStyles/*.xml
-.idea/.idea.osu/.idea/dataSources/*.xml
-.idea/.idea.osu/.idea/dictionaries/*.xml
-.idea/.idea.osu/*.iml
-*.sln.iml
-
-# CodeRush
-.cr/
-
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
-Staging/
+# Cake #
+/tools/**
+/build/tools/**
+/build/temp/**
+
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+.idea/modules.xml
+.idea/*.iml
+.idea/modules
+*.iml
+*.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+# fastlane
+fastlane/report.xml
+
+# inspectcode
inspectcodereport.xml
+inspectcode
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/.idea/.idea.osu.Desktop/.idea/.name b/.idea/.idea.osu.Desktop/.idea/.name
new file mode 100644
index 0000000000..12bf4aebba
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/.name
@@ -0,0 +1 @@
+osu.Desktop
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/codeStyles/codeStyleConfig.xml b/.idea/.idea.osu.Desktop/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000000..a55e7a179b
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/dataSources.xml b/.idea/.idea.osu.Desktop/.idea/dataSources.xml
new file mode 100644
index 0000000000..10f8c1c84d
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/dataSources.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ sqlite.xerial
+ true
+ org.sqlite.JDBC
+ jdbc:sqlite:$USER_HOME$/.local/share/osu/client.db
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/encodings.xml b/.idea/.idea.osu.Desktop/.idea/encodings.xml
new file mode 100644
index 0000000000..15a15b218a
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/indexLayout.xml b/.idea/.idea.osu.Desktop/.idea/indexLayout.xml
new file mode 100644
index 0000000000..27ba142e96
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/misc.xml b/.idea/.idea.osu.Desktop/.idea/misc.xml
new file mode 100644
index 0000000000..1d8c84d0af
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/modules.xml b/.idea/.idea.osu.Desktop/.idea/modules.xml
new file mode 100644
index 0000000000..fe63f5faf3
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/projectSettingsUpdater.xml b/.idea/.idea.osu.Desktop/.idea/projectSettingsUpdater.xml
new file mode 100644
index 0000000000..7515e76054
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/CatchRuleset__Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/CatchRuleset__Tests_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/ManiaRuleset__Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/ManiaRuleset__Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/ManiaRuleset__Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/ManiaRuleset__Tests_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/OsuRuleset__Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/OsuRuleset__Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/OsuRuleset__Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/OsuRuleset__Tests_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/TaikoRuleset__Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/TaikoRuleset__Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/TaikoRuleset__Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/TaikoRuleset__Tests_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/Tournament.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/Tournament.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/Tournament.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/Tournament.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/Tournament__Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/Tournament__Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/Tournament__Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/Tournament__Tests_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/osu_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/osu_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/osu_.xml
diff --git a/.idea/.idea.osu/.idea/runConfigurations/osu___Tests_.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu___Tests_.xml
similarity index 100%
rename from .idea/.idea.osu/.idea/runConfigurations/osu___Tests_.xml
rename to .idea/.idea.osu.Desktop/.idea/runConfigurations/osu___Tests_.xml
diff --git a/.idea/.idea.osu.Desktop/.idea/vcs.xml b/.idea/.idea.osu.Desktop/.idea/vcs.xml
new file mode 100644
index 0000000000..3de04b744c
--- /dev/null
+++ b/.idea/.idea.osu.Desktop/.idea/vcs.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/indexLayout.xml b/.idea/.idea.osu/.idea/indexLayout.xml
new file mode 100644
index 0000000000..27ba142e96
--- /dev/null
+++ b/.idea/.idea.osu/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/modules.xml b/.idea/.idea.osu/.idea/modules.xml
new file mode 100644
index 0000000000..0360fdbc5e
--- /dev/null
+++ b/.idea/.idea.osu/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/projectSettingsUpdater.xml b/.idea/.idea.osu/.idea/projectSettingsUpdater.xml
new file mode 100644
index 0000000000..7515e76054
--- /dev/null
+++ b/.idea/.idea.osu/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/vcs.xml b/.idea/.idea.osu/.idea/vcs.xml
new file mode 100644
index 0000000000..94a25f7f4c
--- /dev/null
+++ b/.idea/.idea.osu/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 70e620bca2..04ff7c1bea 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -100,7 +100,7 @@
"command": "dotnet",
"args": [
"restore",
- "osu.sln"
+ "build/Desktop.proj"
],
"problemMatcher": []
}
diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt
new file mode 100644
index 0000000000..a92191a439
--- /dev/null
+++ b/CodeAnalysis/BannedSymbols.txt
@@ -0,0 +1,6 @@
+M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead.
+M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead.
+M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead.
+M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead.
+T:System.IComparable;Don't use non-generic IComparable. Use generic version instead.
+M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText.
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000000..c0d740bac1
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,42 @@
+
+
+
+ 8.0
+ true
+
+
+ $(MSBuildThisFileDirectory)app.manifest
+
+
+
+ osu.licenseheader
+
+
+
+
+
+
+
+
+
+
+ true
+ $(NoWarn);CS1591
+
+
+
+ $(NoWarn);NU1701
+
+
+ false
+ ppy Pty Ltd
+ MIT
+ https://github.com/ppy/osu
+ https://github.com/ppy/osu
+ Automated release.
+ ppy Pty Ltd
+ Copyright (c) 2019 ppy Pty Ltd
+ osu game
+
+
\ No newline at end of file
diff --git a/build.ps1 b/InspectCode.ps1
old mode 100755
new mode 100644
similarity index 84%
rename from build.ps1
rename to InspectCode.ps1
index 2dbd10a150..6ed935fdbb
--- a/build.ps1
+++ b/InspectCode.ps1
@@ -21,7 +21,7 @@ if ($DryRun) { $cakeArguments += "-dryrun" }
if ($Experimental) { $cakeArguments += "-experimental" }
$cakeArguments += $ScriptArgs
-dotnet tool install Cake.Tool --global --version 0.35.0
-dotnet cake ./build/build.cake --bootstrap
-dotnet cake ./build/build.cake $cakeArguments
+dotnet tool restore
+dotnet cake ./build/InspectCode.cake --bootstrap
+dotnet cake ./build/InspectCode.cake $cakeArguments
exit $LASTEXITCODE
\ No newline at end of file
diff --git a/README.md b/README.md
index 0460e9cbcf..e2e854c755 100644
--- a/README.md
+++ b/README.md
@@ -4,13 +4,16 @@
# osu!
-[](https://ci.appveyor.com/project/peppy/osu) [](https://www.codefactor.io/repository/github/ppy/osu) [](https://discord.gg/ppy)
+[](https://ci.appveyor.com/project/peppy/osu)
+[]()
+[](https://www.codefactor.io/repository/github/ppy/osu)
+[](https://discord.gg/ppy)
-Rhythm is just a *click* away. The future of [osu!](https://osu.ppy.sh) and the beginning of an open era! Commonly known by the codename "osu!lazer". Pew pew.
+Rhythm is just a *click* away. The future of [osu!](https://osu.ppy.sh) and the beginning of an open era! Commonly known by the codename *osu!lazer*. Pew pew.
## Status
-This project is still heavily under development, but is in a state where users are encouraged to try it out and keep it installed alongside the stable osu! client. It will continue to evolve over the coming months and hopefully bring some new unique features to the table.
+This project is still heavily under development, but is in a state where users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve over the coming months and hopefully bring some new unique features to the table.
We are accepting bug reports (please report with as much detail as possible). Feature requests are welcome as long as you read and understand the contribution guidelines listed below.
@@ -19,9 +22,10 @@ Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh
## Requirements
- A desktop platform with the [.NET Core SDK 3.0](https://www.microsoft.com/net/learn/get-started) or higher installed.
-- When running on linux, please have a system-wide ffmpeg installation available to support video decoding.
-- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
-- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio 2017+](https://visualstudio.microsoft.com/vs/), [Jetbrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
+- When running on Linux, please have a system-wide FFmpeg installation available to support video decoding.
+- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?tabs=netcore30&pivots=os-windows)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
+- When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).
+- When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as [Visual Studio 2019+](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
## Running osu!
@@ -55,31 +59,22 @@ git pull
### Building
-Build configurations for the recommended IDEs (listed above) are included. You should use the provided Build/Run functionality of your IDE to get things going. When testing or building new components, it's highly encouraged you use the `VisualTests` project/configuration. More information on this provided [below](#contributing).
+Build configurations for the recommended IDEs (listed above) are included. You should use the provided Build/Run functionality of your IDE to get things going. When testing or building new components, it's highly encouraged you use the `VisualTests` project/configuration. More information on this is provided [below](#contributing).
-> Visual Studio Code users must run the `Restore` task before any build attempt.
+- Visual Studio / Rider users should load the project via one of the platform-specific `.slnf` files, rather than the main `.sln.` This will allow access to template run configurations.
+- Visual Studio Code users must run the `Restore` task before any build attempt.
-You can also build and run osu! from the command-line with a single command:
+You can also build and run *osu!* from the command-line with a single command:
```shell
dotnet run --project osu.Desktop
```
-If you are not interested in debugging osu!, you can add `-c Release` to gain performance. In this case, you must replace `Debug` with `Release` in any commands mentioned in this document.
+If you are not interested in debugging *osu!*, you can add `-c Release` to gain performance. In this case, you must replace `Debug` with `Release` in any commands mentioned in this document.
-If the build fails, try to restore nuget packages with `dotnet restore`.
+If the build fails, try to restore NuGet packages with `dotnet restore`.
-#### A note for Linux users
-
-On Linux, the environment variable `LD_LIBRARY_PATH` must point to the build directory, located at `osu.Desktop/bin/Debug/$NETCORE_VERSION`.
-
-`$NETCORE_VERSION` is the version of the targeted .NET Core SDK. You can check it by running `grep TargetFramework osu.Desktop/osu.Desktop.csproj | sed -r 's/.*>(.*)<\/.*/\1/'`.
-
-For example, you can run osu! with the following command:
-
-```shell
-LD_LIBRARY_PATH="$(pwd)/osu.Desktop/bin/Debug/netcoreapp3.0" dotnet run --project osu.Desktop
-```
+_Due to a historical feature gap between .NET Core and Xamarin, running `dotnet` CLI from the root directory will not work for most commands. This can be resolved by specifying a target `.csproj` or the helper project at `build/Desktop.proj`. Configurations have been provided to work around this issue for all supported IDEs mentioned above._
### Testing with resource/framework modifications
@@ -87,23 +82,27 @@ Sometimes it may be necessary to cross-test changes in [osu-resources](https://g
### Code analysis
-Code analysis can be run with `powershell ./build.ps1` or `build.sh`. This is currently only supported under windows due to [resharper cli shortcomings](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternatively, you can install resharper or use rider to get inline support in your IDE of choice.
+Before committing your code, please run a code formatter. This can be achieved by running `dotnet format` in the command line, or using the `Format code` command in your IDE.
+
+We have adopted some cross-platform, compiler integrated analyzers. They can provide warnings when you are editing, building inside IDE or from command line, as-if they are provided by the compiler itself.
+
+JetBrains ReSharper InspectCode is also used for wider rule sets. You can run it from PowerShell with `.\InspectCode.ps1`, which is [only supported on Windows](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternatively, you can install ReSharper or use Rider to get inline support in your IDE of choice.
## Contributing
-We welcome all contributions, but keep in mind that we already have a lot of the UI designed. If you wish to work on something with the intention on having it included in the official distribution, please open an issue for discussion and we will give you what you need from a design perspective to proceed. If you want to make *changes* to the design, we recommend you open an issue with your intentions before spending too much time, to ensure no effort is wasted.
+We welcome all contributions, but keep in mind that we already have a lot of the UI designed. If you wish to work on something with the intention of having it included in the official distribution, please open an issue for discussion and we will give you what you need from a design perspective to proceed. If you want to make *changes* to the design, we recommend you open an issue with your intentions before spending too much time to ensure no effort is wasted.
If you're unsure of what you can help with, check out the [list of open issues](https://github.com/ppy/osu/issues) (especially those with the ["good first issue"](https://github.com/ppy/osu/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22) label).
Before starting, please make sure you are familiar with the [development and testing](https://github.com/ppy/osu-framework/wiki/Development-and-Testing) procedure we have set up. New component development, and where possible, bug fixing and debugging existing components **should always be done under VisualTests**.
-Note that while we already have certain standards in place, nothing is set in stone. If you have an issue with the way code is structured; with any libraries we are using; with any processes involved with contributing, *please* bring it up. We welcome all feedback so we can make contributing to this project as pain-free as possible.
+Note that while we already have certain standards in place, nothing is set in stone. If you have an issue with the way code is structured, with any libraries we are using, or with any processes involved with contributing, *please* bring it up. We welcome all feedback so we can make contributing to this project as painless as possible.
-For those interested, we love to reward quality contributions via [bounties](https://docs.google.com/spreadsheets/d/1jNXfj_S3Pb5PErA-czDdC9DUu4IgUbe1Lt8E7CYUJuE/view?&rm=minimal#gid=523803337), paid out via paypal or osu! supporter tags. Don't hesitate to [request a bounty](https://docs.google.com/forms/d/e/1FAIpQLSet_8iFAgPMG526pBZ2Kic6HSh7XPM3fE8xPcnWNkMzINDdYg/viewform) for your work on this project.
+For those interested, we love to reward quality contributions via [bounties](https://docs.google.com/spreadsheets/d/1jNXfj_S3Pb5PErA-czDdC9DUu4IgUbe1Lt8E7CYUJuE/view?&rm=minimal#gid=523803337), paid out via PayPal or osu!supporter tags. Don't hesitate to [request a bounty](https://docs.google.com/forms/d/e/1FAIpQLSet_8iFAgPMG526pBZ2Kic6HSh7XPM3fE8xPcnWNkMzINDdYg/viewform) for your work on this project.
## Licence
-The osu! client code and framework are licensed under the [MIT licence](https://opensource.org/licenses/MIT). Please see [the licence file](LICENCE) for more information. [tl;dr](https://tldrlegal.com/license/mit-license) you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source.
+*osu!*'s code and framework are licensed under the [MIT licence](https://opensource.org/licenses/MIT). Please see [the licence file](LICENCE) for more information. [tl;dr](https://tldrlegal.com/license/mit-license) you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source.
Please note that this *does not cover* the usage of the "osu!" or "ppy" branding in any software, resources, advertising or promotion, as this is protected by trademark law.
diff --git a/appveyor.yml b/appveyor.yml
index f59c0b162d..a4a0cedc66 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,6 +1,27 @@
clone_depth: 1
version: '{branch}-{build}'
-image: Visual Studio 2019 Preview
-test: off
-build_script:
- - cmd: PowerShell -Version 2.0 .\build.ps1
+image: Visual Studio 2019
+dotnet_csproj:
+ patch: true
+ file: 'osu.Game\osu.Game.csproj' # Use wildcard when it's able to exclude Xamarin projects
+ version: '0.0.{build}'
+cache:
+ - '%LOCALAPPDATA%\NuGet\v3-cache -> appveyor.yml'
+before_build:
+ - ps: dotnet --info # Useful when version mismatch between CI and local
+ - ps: nuget restore -verbosity quiet # Only nuget.exe knows both new (.NET Core) and old (Xamarin) projects
+build:
+ project: osu.sln
+ parallel: true
+ verbosity: minimal
+ publish_nuget: true
+after_build:
+ - ps: dotnet tool restore
+ - ps: dotnet format --dry-run --check
+ - ps: .\InspectCode.ps1
+test:
+ assemblies:
+ except:
+ - '**\*Android*'
+ - '**\*iOS*'
+ - 'build\**\*'
diff --git a/appveyor_deploy.yml b/appveyor_deploy.yml
index 13635b943c..bb4482f501 100644
--- a/appveyor_deploy.yml
+++ b/appveyor_deploy.yml
@@ -1,10 +1,21 @@
clone_depth: 1
version: '{build}'
-image: Visual Studio 2019 Preview
+image: Visual Studio 2019
+dotnet_csproj:
+ patch: true
+ file: 'osu.Game\osu.Game.csproj' # Use wildcard when it's able to exclude Xamarin projects
+ version: $(APPVEYOR_REPO_TAG_NAME)
+before_build:
+ - ps: dotnet --info # Useful when version mismatch between CI and local
+ - ps: nuget restore -verbosity quiet # Only nuget.exe knows both new (.NET Core) and old (Xamarin) projects
test: off
skip_non_tags: true
-build_script:
- - cmd: PowerShell -Version 2.0 .\build.ps1
+configuration: Release
+build:
+ project: build\Desktop.proj # Skipping Xamarin Release that's slow and covered by fastlane
+ parallel: true
+ verbosity: minimal
+ publish_nuget: true
deploy:
- provider: Environment
name: nuget
diff --git a/assets/lazer-nuget.png b/assets/lazer-nuget.png
new file mode 100644
index 0000000000..c2a587fdc2
Binary files /dev/null and b/assets/lazer-nuget.png differ
diff --git a/build.sh b/build.sh
deleted file mode 100755
index ac6bd877a6..0000000000
--- a/build.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-echo "Installing Cake.Tool..."
-dotnet tool install Cake.Tool --global --version 0.35.0
-
-# Parse arguments.
-CAKE_ARGUMENTS=()
-for i in "$@"; do
- case $1 in
- -s|--script) SCRIPT="$2"; shift ;;
- --) shift; CAKE_ARGUMENTS+=("$@"); break ;;
- *) CAKE_ARGUMENTS+=("$1") ;;
- esac
- shift
-done
-
-echo "Running build script..."
-dotnet cake ./build/build.cake --bootstrap
-dotnet cake ./build/build.cake "${CAKE_ARGUMENTS[@]}"
\ No newline at end of file
diff --git a/build/Desktop.proj b/build/Desktop.proj
new file mode 100644
index 0000000000..b1c6b065e8
--- /dev/null
+++ b/build/Desktop.proj
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/build.cake b/build/InspectCode.cake
similarity index 61%
rename from build/build.cake
rename to build/InspectCode.cake
index cfdfebee61..bd3fdf5f93 100644
--- a/build/build.cake
+++ b/build/InspectCode.cake
@@ -7,43 +7,29 @@ var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
-var target = Argument("target", "Build");
+var target = Argument("target", "CodeAnalysis");
var configuration = Argument("configuration", "Release");
var rootDirectory = new DirectoryPath("..");
-var solution = rootDirectory.CombineWithFilePath("osu.sln");
+var sln = rootDirectory.CombineWithFilePath("osu.sln");
+var desktopSlnf = rootDirectory.CombineWithFilePath("osu.Desktop.slnf");
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
-Task("Compile")
- .Does(() => {
- DotNetCoreBuild(solution.FullPath, new DotNetCoreBuildSettings {
- Configuration = configuration,
- });
- });
-
-Task("Test")
- .IsDependentOn("Compile")
- .Does(() => {
- var testAssemblies = GetFiles(rootDirectory + "/**/*.Tests/bin/**/*.Tests.dll");
-
- DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings {
- Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx",
- Parallel = true,
- ToolTimeout = TimeSpan.FromMinutes(10),
- });
- });
-
-// windows only because both inspectcore and nvika depend on net45
+// windows only because both inspectcode and nvika depend on net45
Task("InspectCode")
.WithCriteria(IsRunningOnWindows())
- .IsDependentOn("Compile")
.Does(() => {
- InspectCode(solution, new InspectCodeSettings {
+ InspectCode(desktopSlnf, new InspectCodeSettings {
CachesHome = "inspectcode",
OutputFile = "inspectcodereport.xml",
+ ArgumentCustomization = arg => {
+ if (AppVeyor.IsRunningOnAppVeyor) // Don't flood CI output
+ arg.Append("--verbosity:WARN");
+ return arg;
+ },
});
int returnCode = StartProcess(nVikaToolPath, $@"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors");
@@ -59,9 +45,8 @@ Task("CodeFileSanity")
});
});
-Task("Build")
+Task("CodeAnalysis")
.IsDependentOn("CodeFileSanity")
- .IsDependentOn("InspectCode")
- .IsDependentOn("Test");
+ .IsDependentOn("InspectCode");
RunTarget(target);
\ No newline at end of file
diff --git a/fastlane/Fastfile b/fastlane/Fastfile
index 7adf42a1eb..28a83fbbae 100644
--- a/fastlane/Fastfile
+++ b/fastlane/Fastfile
@@ -49,12 +49,12 @@ desc 'Deploy to play store'
desc 'Compile the project'
lane :build do |options|
nuget_restore(
- project_path: 'osu.Android.sln'
+ project_path: 'osu.sln'
)
souyuz(
build_configuration: 'Release',
- solution_path: 'osu.Android.sln',
+ solution_path: 'osu.sln',
platform: "android",
output_path: "osu.Android/bin/Release/",
keystore_path: options[:keystore_path],
@@ -70,7 +70,7 @@ desc 'Deploy to play store'
android_build = split.join('')
app_version(
- solution_path: 'osu.Android.sln',
+ solution_path: 'osu.sln',
version: options[:version],
build: android_build,
)
@@ -106,7 +106,7 @@ platform :ios do
desc 'Compile the project'
lane :build do
nuget_restore(
- project_path: 'osu.iOS.sln'
+ project_path: 'osu.sln'
)
souyuz(
diff --git a/global.json b/global.json
new file mode 100644
index 0000000000..43bb34912a
--- /dev/null
+++ b/global.json
@@ -0,0 +1,5 @@
+{
+ "msbuild-sdks": {
+ "Microsoft.Build.Traversal": "2.0.24"
+ }
+}
\ No newline at end of file
diff --git a/osu.Android.props b/osu.Android.props
index 85766665a9..3cd4dc48bf 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -1,51 +1,43 @@
- Debug
- AnyCPU
+ 8.0
bin\$(Configuration)
4
2.0
false
false
- default
Library
512
Off
True
Xamarin.Android.Net.AndroidClientHandler
- v9.0
+ v10.0
false
+ true
+ armeabi-v7a;x86;arm64-v8a
+ true
+ cjk,mideast,other,rare,west
+ SdkOnly
+ prompt
-
+
True
portable
False
DEBUG;TRACE
- prompt
false
false
- SdkOnly
true
false
- cjk,mideast,other,rare,west
- true
- armeabi-v7a;x86;arm64-v8a
- true
-
+
false
None
True
- prompt
true
false
- SdkOnly
False
true
- cjk,mideast,other,rare,west
- true
- armeabi-v7a;x86;arm64-v8a
- true
@@ -62,6 +54,6 @@
-
+
diff --git a/osu.Android.sln b/osu.Android.sln
deleted file mode 100644
index ebf2c55cb4..0000000000
--- a/osu.Android.sln
+++ /dev/null
@@ -1,126 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.28516.95
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game", "osu.Game\osu.Game.csproj", "{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Osu", "osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj", "{C92A607B-1FDD-4954-9F92-03FF547D9080}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Catch", "osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj", "{58F6C80C-1253-4A0E-A465-B8C85EBEADF3}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Taiko", "osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj", "{F167E17A-7DE6-4AF5-B920-A5112296C695}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Mania", "osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj", "{48F4582B-7687-4621-9CBE-5C24197CB536}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Android", "osu.Android\osu.Android.csproj", "{D1D5F9A8-B40B-40E6-B02F-482D03346D3D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Catch.Tests.Android", "osu.Game.Rulesets.Catch.Tests.Android\osu.Game.Rulesets.Catch.Tests.Android.csproj", "{C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Mania.Tests.Android", "osu.Game.Rulesets.Mania.Tests.Android\osu.Game.Rulesets.Mania.Tests.Android.csproj", "{531F1092-DB27-445D-AA33-2A77C7187C99}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Osu.Tests.Android", "osu.Game.Rulesets.Osu.Tests.Android\osu.Game.Rulesets.Osu.Tests.Android.csproj", "{90CAB706-39CB-4B93-9629-3218A6FF8E9B}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Taiko.Tests.Android", "osu.Game.Rulesets.Taiko.Tests.Android\osu.Game.Rulesets.Taiko.Tests.Android.csproj", "{3701A0A1-8476-42C6-B5C4-D24129B4A484}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Tests.Android", "osu.Game.Tests.Android\osu.Game.Tests.Android.csproj", "{5CC222DC-5716-4499-B897-DCBDDA4A5CF9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU
- {C92A607B-1FDD-4954-9F92-03FF547D9080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C92A607B-1FDD-4954-9F92-03FF547D9080}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C92A607B-1FDD-4954-9F92-03FF547D9080}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C92A607B-1FDD-4954-9F92-03FF547D9080}.Release|Any CPU.Build.0 = Release|Any CPU
- {58F6C80C-1253-4A0E-A465-B8C85EBEADF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {58F6C80C-1253-4A0E-A465-B8C85EBEADF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {58F6C80C-1253-4A0E-A465-B8C85EBEADF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {58F6C80C-1253-4A0E-A465-B8C85EBEADF3}.Release|Any CPU.Build.0 = Release|Any CPU
- {F167E17A-7DE6-4AF5-B920-A5112296C695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F167E17A-7DE6-4AF5-B920-A5112296C695}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F167E17A-7DE6-4AF5-B920-A5112296C695}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F167E17A-7DE6-4AF5-B920-A5112296C695}.Release|Any CPU.Build.0 = Release|Any CPU
- {48F4582B-7687-4621-9CBE-5C24197CB536}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {48F4582B-7687-4621-9CBE-5C24197CB536}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {48F4582B-7687-4621-9CBE-5C24197CB536}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {48F4582B-7687-4621-9CBE-5C24197CB536}.Release|Any CPU.Build.0 = Release|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Release|Any CPU.Build.0 = Release|Any CPU
- {D1D5F9A8-B40B-40E6-B02F-482D03346D3D}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Release|Any CPU.Build.0 = Release|Any CPU
- {C5379ECB-3A94-4D2F-AC3B-2615AC23EB0D}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Release|Any CPU.Build.0 = Release|Any CPU
- {531F1092-DB27-445D-AA33-2A77C7187C99}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Release|Any CPU.Build.0 = Release|Any CPU
- {90CAB706-39CB-4B93-9629-3218A6FF8E9B}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Release|Any CPU.Build.0 = Release|Any CPU
- {3701A0A1-8476-42C6-B5C4-D24129B4A484}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Release|Any CPU.Build.0 = Release|Any CPU
- {5CC222DC-5716-4499-B897-DCBDDA4A5CF9}.Release|Any CPU.Deploy.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {671B0BEC-2403-45B0-9357-2C97CC517668}
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- Policies = $0
- $0.TextStylePolicy = $1
- $1.EolMarker = Windows
- $1.inheritsSet = VisualStudio
- $1.inheritsScope = text/plain
- $1.scope = text/x-csharp
- $0.CSharpFormattingPolicy = $2
- $2.IndentSwitchSection = True
- $2.NewLinesForBracesInProperties = True
- $2.NewLinesForBracesInAccessors = True
- $2.NewLinesForBracesInAnonymousMethods = True
- $2.NewLinesForBracesInControlBlocks = True
- $2.NewLinesForBracesInAnonymousTypes = True
- $2.NewLinesForBracesInObjectCollectionArrayInitializers = True
- $2.NewLinesForBracesInLambdaExpressionBody = True
- $2.NewLineForElse = True
- $2.NewLineForCatch = True
- $2.NewLineForFinally = True
- $2.NewLineForMembersInObjectInit = True
- $2.NewLineForMembersInAnonymousTypes = True
- $2.NewLineForClausesInQuery = True
- $2.SpacingAfterMethodDeclarationName = False
- $2.SpaceAfterMethodCallName = False
- $2.SpaceBeforeOpenSquareBracket = False
- $2.inheritsSet = Mono
- $2.inheritsScope = text/x-csharp
- $2.scope = text/x-csharp
- EndGlobalSection
-EndGlobal
diff --git a/osu.Android.sln.DotSettings b/osu.Android.sln.DotSettings
deleted file mode 100644
index 5a97fc7518..0000000000
--- a/osu.Android.sln.DotSettings
+++ /dev/null
@@ -1,834 +0,0 @@
-
- True
- True
- True
- True
- ExplicitlyExcluded
- ExplicitlyExcluded
- SOLUTION
- HINT
- WARNING
-
- True
- WARNING
- WARNING
- HINT
- HINT
- HINT
- HINT
- WARNING
- WARNING
- WARNING
- HINT
- WARNING
- HINT
- SUGGESTION
- HINT
- HINT
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- WARNING
- WARNING
- HINT
- WARNING
- WARNING
- DO_NOT_SHOW
- HINT
- WARNING
- DO_NOT_SHOW
- WARNING
- HINT
- HINT
- HINT
- ERROR
- HINT
- HINT
- HINT
- WARNING
- WARNING
- HINT
- DO_NOT_SHOW
- HINT
- HINT
- HINT
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- HINT
- HINT
- HINT
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- DO_NOT_SHOW
- DO_NOT_SHOW
- DO_NOT_SHOW
- WARNING
-
- WARNING
- WARNING
- WARNING
- ERROR
- WARNING
- WARNING
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- DO_NOT_SHOW
- DO_NOT_SHOW
- DO_NOT_SHOW
- WARNING
- WARNING
- HINT
- WARNING
- HINT
- HINT
- HINT
- HINT
- HINT
- HINT
- HINT
-
- HINT
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- WARNING
- HINT
- WARNING
- WARNING
- HINT
- HINT
- WARNING
- <?xml version="1.0" encoding="utf-16"?><Profile name="Code Cleanup (peppy)"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSUpdateFileHeader>True</CSUpdateFileHeader><CSCodeStyleAttributes ArrangeTypeAccessModifier="False" ArrangeTypeMemberAccessModifier="False" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="False" ArrangeArgumentsStyle="False" /><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSArrangeQualifiers>True</CSArrangeQualifiers></Profile>
- Code Cleanup (peppy)
- Required
- Required
- Required
- Explicit
- ExpressionBody
- ExpressionBody
- True
- NEXT_LINE
- True
- True
- True
- True
- True
- True
- True
- True
- NEXT_LINE
- 1
- 1
- NEXT_LINE
- MULTILINE
- NEXT_LINE
- 1
- 1
- True
- NEXT_LINE
- NEVER
- NEVER
- True
- False
- True
- NEVER
- False
- False
- True
- False
- False
- True
- True
- False
- False
- CHOP_IF_LONG
- True
- 200
- CHOP_IF_LONG
- False
- False
- AABB
- API
- BPM
- GC
- GL
- GLSL
- HID
- HUD
- ID
- IP
- IPC
- LTRB
- MD5
- NS
- OS
- RGB
- RNG
- SHA
- SRGB
- TK
- SS
- PP
- GMT
- QAT
- BNG
- UI
- HINT
- <?xml version="1.0" encoding="utf-16"?>
-<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
- <TypePattern DisplayName="COM interfaces or structs">
- <TypePattern.Match>
- <Or>
- <And>
- <Kind Is="Interface" />
- <Or>
- <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" />
- <HasAttribute Name="System.Runtime.InteropServices.ComImport" />
- </Or>
- </And>
- <Kind Is="Struct" />
- </Or>
- </TypePattern.Match>
- </TypePattern>
- <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All">
- <TypePattern.Match>
- <And>
- <Kind Is="Class" />
- <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" />
- </And>
- </TypePattern.Match>
- <Entry DisplayName="Setup/Teardown Methods">
- <Entry.Match>
- <And>
- <Kind Is="Method" />
- <Or>
- <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" />
- <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" />
- <HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" />
- <HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" />
- </Or>
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="All other members" />
- <Entry Priority="100" DisplayName="Test Methods">
- <Entry.Match>
- <And>
- <Kind Is="Method" />
- <HasAttribute Name="NUnit.Framework.TestAttribute" />
- </And>
- </Entry.Match>
- <Entry.SortBy>
- <Name />
- </Entry.SortBy>
- </Entry>
- </TypePattern>
- <TypePattern DisplayName="Default Pattern">
- <Group DisplayName="Fields/Properties">
- <Group DisplayName="Public Fields">
- <Entry DisplayName="Constant Fields">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Or>
- <Kind Is="Constant" />
- <Readonly />
- <And>
- <Static />
- <Readonly />
- </And>
- </Or>
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Static Fields">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Static />
- <Not>
- <Readonly />
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Normal Fields">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Not>
- <Or>
- <Static />
- <Readonly />
- </Or>
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Entry DisplayName="Public Properties">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Kind Is="Property" />
- </And>
- </Entry.Match>
- </Entry>
- <Group DisplayName="Internal Fields">
- <Entry DisplayName="Constant Fields">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Or>
- <Kind Is="Constant" />
- <Readonly />
- <And>
- <Static />
- <Readonly />
- </And>
- </Or>
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Static Fields">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Static />
- <Not>
- <Readonly />
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Normal Fields">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Not>
- <Or>
- <Static />
- <Readonly />
- </Or>
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Entry DisplayName="Internal Properties">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Kind Is="Property" />
- </And>
- </Entry.Match>
- </Entry>
- <Group DisplayName="Protected Fields">
- <Entry DisplayName="Constant Fields">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Or>
- <Kind Is="Constant" />
- <Readonly />
- <And>
- <Static />
- <Readonly />
- </And>
- </Or>
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Static Fields">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Static />
- <Not>
- <Readonly />
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Normal Fields">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Not>
- <Or>
- <Static />
- <Readonly />
- </Or>
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Entry DisplayName="Protected Properties">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Kind Is="Property" />
- </And>
- </Entry.Match>
- </Entry>
- <Group DisplayName="Private Fields">
- <Entry DisplayName="Constant Fields">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Or>
- <Kind Is="Constant" />
- <Readonly />
- <And>
- <Static />
- <Readonly />
- </And>
- </Or>
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Static Fields">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Static />
- <Not>
- <Readonly />
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Normal Fields">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Not>
- <Or>
- <Static />
- <Readonly />
- </Or>
- </Not>
- <Kind Is="Field" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Entry DisplayName="Private Properties">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Kind Is="Property" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Group DisplayName="Constructor/Destructor">
- <Entry DisplayName="Ctor">
- <Entry.Match>
- <Kind Is="Constructor" />
- </Entry.Match>
- </Entry>
- <Region Name="Disposal">
- <Entry DisplayName="Dtor">
- <Entry.Match>
- <Kind Is="Destructor" />
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Dispose()">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Kind Is="Method" />
- <Name Is="Dispose" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Dispose(true)">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Or>
- <Virtual />
- <Override />
- </Or>
- <Kind Is="Method" />
- <Name Is="Dispose" />
- </And>
- </Entry.Match>
- </Entry>
- </Region>
- </Group>
- <Group DisplayName="Methods">
- <Group DisplayName="Public">
- <Entry DisplayName="Static Methods">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Static />
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Methods">
- <Entry.Match>
- <And>
- <Access Is="Public" />
- <Not>
- <Static />
- </Not>
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Group DisplayName="Internal">
- <Entry DisplayName="Static Methods">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Static />
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Methods">
- <Entry.Match>
- <And>
- <Access Is="Internal" />
- <Not>
- <Static />
- </Not>
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Group DisplayName="Protected">
- <Entry DisplayName="Static Methods">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Static />
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Methods">
- <Entry.Match>
- <And>
- <Access Is="Protected" />
- <Not>
- <Static />
- </Not>
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- <Group DisplayName="Private">
- <Entry DisplayName="Static Methods">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Static />
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- <Entry DisplayName="Methods">
- <Entry.Match>
- <And>
- <Access Is="Private" />
- <Not>
- <Static />
- </Not>
- <Kind Is="Method" />
- </And>
- </Entry.Match>
- </Entry>
- </Group>
- </Group>
- </TypePattern>
-</Patterns>
- Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
-See the LICENCE file in the repository root for full licence text.
-
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy>
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="private methods"><ElementKinds><Kind Name="ASYNC_METHOD" /><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
- <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public" Description="internal/protected/public methods"><ElementKinds><Kind Name="ASYNC_METHOD" /><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy>
- <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="private properties"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
- <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public" Description="internal/protected/public properties"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy>
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- o!f – Object Initializer: Anchor&Origin
- True
- constant("Centre")
- 0
- True
- True
- 2.0
- InCSharpFile
- ofao
- True
- Anchor = Anchor.$anchor$,
-Origin = Anchor.$anchor$,
- True
- True
- o!f – InternalChildren = []
- True
- True
- 2.0
- InCSharpFile
- ofic
- True
- InternalChildren = new Drawable[]
-{
- $END$
-};
- True
- True
- o!f – new GridContainer { .. }
- True
- True
- 2.0
- InCSharpFile
- ofgc
- True
- new GridContainer
-{
- RelativeSizeAxes = Axes.Both,
- Content = new[]
- {
- new Drawable[] { $END$ },
- new Drawable[] { }
- }
-};
- True
- True
- o!f – new FillFlowContainer { .. }
- True
- True
- 2.0
- InCSharpFile
- offf
- True
- new FillFlowContainer
-{
- RelativeSizeAxes = Axes.Both,
- Direction = FillDirection.Vertical,
- Children = new Drawable[]
- {
- $END$
- }
-},
- True
- True
- o!f – new Container { .. }
- True
- True
- 2.0
- InCSharpFile
- ofcont
- True
- new Container
-{
- RelativeSizeAxes = Axes.Both,
- Children = new Drawable[]
- {
- $END$
- }
-},
- True
- True
- o!f – BackgroundDependencyLoader load()
- True
- True
- 2.0
- InCSharpFile
- ofbdl
- True
- [BackgroundDependencyLoader]
-private void load()
-{
- $END$
-}
- True
- True
- o!f – new Box { .. }
- True
- True
- 2.0
- InCSharpFile
- ofbox
- True
- new Box
-{
- Colour = Color4.Black,
- RelativeSizeAxes = Axes.Both,
-},
- True
- True
- o!f – Children = []
- True
- True
- 2.0
- InCSharpFile
- ofc
- True
- Children = new Drawable[]
-{
- $END$
-};
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
- True
diff --git a/osu.Android.slnf b/osu.Android.slnf
new file mode 100644
index 0000000000..7d90f97eb9
--- /dev/null
+++ b/osu.Android.slnf
@@ -0,0 +1,19 @@
+{
+ "solution": {
+ "path": "osu.sln",
+ "projects": [
+ "osu.Android\\osu.Android.csproj",
+ "osu.Game.Rulesets.Catch.Tests.Android\\osu.Game.Rulesets.Catch.Tests.Android.csproj",
+ "osu.Game.Rulesets.Catch\\osu.Game.Rulesets.Catch.csproj",
+ "osu.Game.Rulesets.Mania.Tests.Android\\osu.Game.Rulesets.Mania.Tests.Android.csproj",
+ "osu.Game.Rulesets.Mania\\osu.Game.Rulesets.Mania.csproj",
+ "osu.Game.Rulesets.Osu.Tests.Android\\osu.Game.Rulesets.Osu.Tests.Android.csproj",
+ "osu.Game.Rulesets.Osu\\osu.Game.Rulesets.Osu.csproj",
+ "osu.Game.Rulesets.Taiko.Tests.Android\\osu.Game.Rulesets.Taiko.Tests.Android.csproj",
+ "osu.Game.Rulesets.Taiko\\osu.Game.Rulesets.Taiko.csproj",
+ "osu.Game.Tests.Android\\osu.Game.Tests.Android.csproj",
+ "osu.Game.Tests\\osu.Game.Tests.csproj",
+ "osu.Game\\osu.Game.csproj"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/osu.Android/OsuGameActivity.cs b/osu.Android/OsuGameActivity.cs
index 762a9c418d..2e5fa59d20 100644
--- a/osu.Android/OsuGameActivity.cs
+++ b/osu.Android/OsuGameActivity.cs
@@ -16,6 +16,11 @@ namespace osu.Android
protected override void OnCreate(Bundle savedInstanceState)
{
+ // The default current directory on android is '/'.
+ // On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
+ // In order to have a consistent current directory on all devices the full path of the app data directory is set as the current directory.
+ System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
+
base.OnCreate(savedInstanceState);
Window.AddFlags(WindowManagerFlags.Fullscreen);
diff --git a/osu.Android/Properties/AndroidManifest.xml b/osu.Android/Properties/AndroidManifest.xml
index acd21f9587..770eaf2222 100644
--- a/osu.Android/Properties/AndroidManifest.xml
+++ b/osu.Android/Properties/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/osu.Desktop.slnf b/osu.Desktop.slnf
new file mode 100644
index 0000000000..e6b6446f72
--- /dev/null
+++ b/osu.Desktop.slnf
@@ -0,0 +1,20 @@
+{
+ "solution": {
+ "path": "osu.sln",
+ "projects": [
+ "osu.Desktop\\osu.Desktop.csproj",
+ "osu.Game.Rulesets.Catch.Tests\\osu.Game.Rulesets.Catch.Tests.csproj",
+ "osu.Game.Rulesets.Catch\\osu.Game.Rulesets.Catch.csproj",
+ "osu.Game.Rulesets.Mania.Tests\\osu.Game.Rulesets.Mania.Tests.csproj",
+ "osu.Game.Rulesets.Mania\\osu.Game.Rulesets.Mania.csproj",
+ "osu.Game.Rulesets.Osu.Tests\\osu.Game.Rulesets.Osu.Tests.csproj",
+ "osu.Game.Rulesets.Osu\\osu.Game.Rulesets.Osu.csproj",
+ "osu.Game.Rulesets.Taiko.Tests\\osu.Game.Rulesets.Taiko.Tests.csproj",
+ "osu.Game.Rulesets.Taiko\\osu.Game.Rulesets.Taiko.csproj",
+ "osu.Game.Tests\\osu.Game.Tests.csproj",
+ "osu.Game.Tournament.Tests\\osu.Game.Tournament.Tests.csproj",
+ "osu.Game.Tournament\\osu.Game.Tournament.csproj",
+ "osu.Game\\osu.Game.csproj"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs
index 7725ee6451..66e7bb381c 100644
--- a/osu.Desktop/OsuGameDesktop.cs
+++ b/osu.Desktop/OsuGameDesktop.cs
@@ -112,14 +112,14 @@ namespace osu.Desktop
{
protected override string LocateBasePath()
{
- bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs"));
+ static bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs"));
string stableInstallPath;
try
{
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
- stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(String.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
+ stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
if (checkExists(stableInstallPath))
return stableInstallPath;
diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs
index 6eed46867a..8c759f8487 100644
--- a/osu.Desktop/Overlays/VersionManager.cs
+++ b/osu.Desktop/Overlays/VersionManager.cs
@@ -15,7 +15,7 @@ using osuTK.Graphics;
namespace osu.Desktop.Overlays
{
- public class VersionManager : OverlayContainer
+ public class VersionManager : VisibilityContainer
{
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures, OsuGameBase game)
diff --git a/osu.Desktop/Properties/launchSettings.json b/osu.Desktop/Properties/launchSettings.json
new file mode 100644
index 0000000000..5e768ec9fa
--- /dev/null
+++ b/osu.Desktop/Properties/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "profiles": {
+ "osu! Desktop": {
+ "commandName": "Project"
+ },
+ "osu! Tournament": {
+ "commandName": "Project",
+ "commandLineArgs": "--tournament"
+ }
+ }
+}
\ No newline at end of file
diff --git a/osu.Desktop/app.manifest b/osu.Desktop/app.manifest
new file mode 100644
index 0000000000..2e9127bf44
--- /dev/null
+++ b/osu.Desktop/app.manifest
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
\ No newline at end of file
diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj
index 2d1282634f..60cada3ae7 100644
--- a/osu.Desktop/osu.Desktop.csproj
+++ b/osu.Desktop/osu.Desktop.csproj
@@ -1,15 +1,14 @@
-
netcoreapp3.0
WinExe
- AnyCPU
true
click the circles. to the beat.
osu!
osu!lazer
osu!lazer
lazer.ico
+ app.manifest
0.0.0
0.0.0
@@ -23,13 +22,13 @@
-
-
+
+
diff --git a/osu.Game.Rulesets.Catch.Tests.Android/Properties/AndroidManifest.xml b/osu.Game.Rulesets.Catch.Tests.Android/Properties/AndroidManifest.xml
index db95e18f13..f8c3fcd894 100644
--- a/osu.Game.Rulesets.Catch.Tests.Android/Properties/AndroidManifest.xml
+++ b/osu.Game.Rulesets.Catch.Tests.Android/Properties/AndroidManifest.xml
@@ -1,5 +1,6 @@
-
-
+
+
+
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Catch.Tests.iOS/osu.Game.Rulesets.Catch.Tests.iOS.csproj b/osu.Game.Rulesets.Catch.Tests.iOS/osu.Game.Rulesets.Catch.Tests.iOS.csproj
index 7990c35e09..be6044bbd0 100644
--- a/osu.Game.Rulesets.Catch.Tests.iOS/osu.Game.Rulesets.Catch.Tests.iOS.csproj
+++ b/osu.Game.Rulesets.Catch.Tests.iOS/osu.Game.Rulesets.Catch.Tests.iOS.csproj
@@ -1,6 +1,5 @@
-
+
-
Debug
iPhoneSimulator
@@ -33,5 +32,4 @@
-
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs
index 720ef1db42..9b529a2e4c 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs
@@ -11,12 +11,12 @@ using System;
using System.Collections.Generic;
using osu.Game.Skinning;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Sprites;
using osuTK.Graphics;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
+using osu.Game.Graphics.Sprites;
namespace osu.Game.Rulesets.Catch.Tests
{
@@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Catch.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.Blue
},
- new SpriteText
+ new OsuSpriteText
{
Text = "custom"
}
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
index 7a9b61c60c..0369b6db4e 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
@@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Catch.Tests
private void load()
{
var controlPointInfo = new ControlPointInfo();
- controlPointInfo.TimingPoints.Add(new TimingControlPoint());
+ controlPointInfo.Add(0, new TimingControlPoint());
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
{
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
index 7b8c699f2c..da36673930 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
@@ -40,8 +40,10 @@ namespace osu.Game.Rulesets.Catch.Tests
beatmap.HitObjects.Add(new Fruit { StartTime = 1008, X = 56 / 512f, });
for (int i = 0; i < 512; i++)
+ {
if (i % 5 < 3)
beatmap.HitObjects.Add(new Fruit { X = i % 10 < 5 ? 0.02f : 0.98f, StartTime = 2000 + i * 100, NewCombo = i % 8 == 0 });
+ }
return beatmap;
}
diff --git a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
index 4b629902cb..1dbe9b39ee 100644
--- a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
+++ b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
index 0d9a663b9f..b5497ea89f 100644
--- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
@@ -8,6 +8,7 @@ using System;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Objects;
+using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Catch.Beatmaps
{
@@ -22,48 +23,44 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
protected override IEnumerable ConvertHitObject(HitObject obj, IBeatmap beatmap)
{
- var curveData = obj as IHasCurve;
var positionData = obj as IHasXPosition;
var comboData = obj as IHasCombo;
- var endTime = obj as IHasEndTime;
- var legacyOffset = obj as IHasLegacyLastTickOffset;
- if (curveData != null)
+ switch (obj)
{
- yield return new JuiceStream
- {
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- Path = curveData.Path,
- NodeSamples = curveData.NodeSamples,
- RepeatCount = curveData.RepeatCount,
- X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
- NewCombo = comboData?.NewCombo ?? false,
- ComboOffset = comboData?.ComboOffset ?? 0,
- LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset ?? 0
- };
- }
- else if (endTime != null)
- {
- yield return new BananaShower
- {
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- Duration = endTime.Duration,
- NewCombo = comboData?.NewCombo ?? false,
- ComboOffset = comboData?.ComboOffset ?? 0,
- };
- }
- else
- {
- yield return new Fruit
- {
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- NewCombo = comboData?.NewCombo ?? false,
- ComboOffset = comboData?.ComboOffset ?? 0,
- X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
- };
+ case IHasCurve curveData:
+ return new JuiceStream
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ Path = curveData.Path,
+ NodeSamples = curveData.NodeSamples,
+ RepeatCount = curveData.RepeatCount,
+ X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
+ NewCombo = comboData?.NewCombo ?? false,
+ ComboOffset = comboData?.ComboOffset ?? 0,
+ LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
+ }.Yield();
+
+ case IHasEndTime endTime:
+ return new BananaShower
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ Duration = endTime.Duration,
+ NewCombo = comboData?.NewCombo ?? false,
+ ComboOffset = comboData?.ComboOffset ?? 0,
+ }.Yield();
+
+ default:
+ return new Fruit
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ NewCombo = comboData?.NewCombo ?? false,
+ ComboOffset = comboData?.ComboOffset ?? 0,
+ X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
+ }.Yield();
}
}
diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
index 5ab47c1611..db52fbac1b 100644
--- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
+++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
@@ -8,7 +8,6 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types;
-using osuTK;
using osu.Game.Rulesets.Catch.MathUtils;
using osu.Game.Rulesets.Mods;
@@ -78,7 +77,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
catchObject.XOffset = 0;
if (catchObject is TinyDroplet)
- catchObject.XOffset = MathHelper.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -catchObject.X, 1 - catchObject.X);
+ catchObject.XOffset = Math.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -catchObject.X, 1 - catchObject.X);
else if (catchObject is Droplet)
rng.Next(); // osu!stable retrieved a random droplet rotation
}
@@ -195,10 +194,15 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
{
if (currentObject is Fruit)
objectWithDroplets.Add(currentObject);
+
if (currentObject is JuiceStream)
+ {
foreach (var currentJuiceElement in currentObject.NestedHitObjects)
+ {
if (!(currentJuiceElement is TinyDroplet))
objectWithDroplets.Add((CatchHitObject)currentJuiceElement);
+ }
+ }
}
objectWithDroplets.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
@@ -225,7 +229,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
else
{
currentObject.DistanceToHyperDash = distanceToHyper;
- lastExcess = MathHelper.Clamp(distanceToHyper, 0, halfCatcherWidth);
+ lastExcess = Math.Clamp(distanceToHyper, 0, halfCatcherWidth);
}
lastDirection = thisDirection;
diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs
index 5a640f6d1a..a6283eb7c4 100644
--- a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs
+++ b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs
@@ -10,7 +10,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
-using osuTK;
namespace osu.Game.Rulesets.Catch.Difficulty
{
@@ -35,12 +34,10 @@ namespace osu.Game.Rulesets.Catch.Difficulty
{
mods = Score.Mods;
- var legacyScore = Score as LegacyScoreInfo;
-
- fruitsHit = legacyScore?.Count300 ?? Score.Statistics[HitResult.Perfect];
- ticksHit = legacyScore?.Count100 ?? 0;
- tinyTicksHit = legacyScore?.Count50 ?? 0;
- tinyTicksMissed = legacyScore?.CountKatu ?? 0;
+ fruitsHit = Score?.GetCount300() ?? Score.Statistics[HitResult.Perfect];
+ ticksHit = Score?.GetCount100() ?? 0;
+ tinyTicksHit = Score?.GetCount50() ?? 0;
+ tinyTicksMissed = Score?.GetCountKatu() ?? 0;
misses = Score.Statistics[HitResult.Miss];
// Don't count scores made with supposedly unranked mods
@@ -48,55 +45,53 @@ namespace osu.Game.Rulesets.Catch.Difficulty
return 0;
// We are heavily relying on aim in catch the beat
- double value = Math.Pow(5.0f * Math.Max(1.0f, Attributes.StarRating / 0.0049f) - 4.0f, 2.0f) / 100000.0f;
+ double value = Math.Pow(5.0 * Math.Max(1.0, Attributes.StarRating / 0.0049) - 4.0, 2.0) / 100000.0;
// Longer maps are worth more. "Longer" means how many hits there are which can contribute to combo
int numTotalHits = totalComboHits();
// Longer maps are worth more
- float lengthBonus =
- 0.95f + 0.4f * Math.Min(1.0f, numTotalHits / 3000.0f) +
- (numTotalHits > 3000 ? (float)Math.Log10(numTotalHits / 3000.0f) * 0.5f : 0.0f);
+ double lengthBonus =
+ 0.95 + 0.4 * Math.Min(1.0, numTotalHits / 3000.0) +
+ (numTotalHits > 3000 ? Math.Log10(numTotalHits / 3000.0) * 0.5 : 0.0);
// Longer maps are worth more
value *= lengthBonus;
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
- value *= Math.Pow(0.97f, misses);
+ value *= Math.Pow(0.97, misses);
// Combo scaling
- float beatmapMaxCombo = Attributes.MaxCombo;
- if (beatmapMaxCombo > 0)
- value *= Math.Min(Math.Pow(Attributes.MaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);
+ if (Attributes.MaxCombo > 0)
+ value *= Math.Min(Math.Pow(Attributes.MaxCombo, 0.8) / Math.Pow(Attributes.MaxCombo, 0.8), 1.0);
- float approachRate = (float)Attributes.ApproachRate;
- float approachRateFactor = 1.0f;
- if (approachRate > 9.0f)
- approachRateFactor += 0.1f * (approachRate - 9.0f); // 10% for each AR above 9
- else if (approachRate < 8.0f)
- approachRateFactor += 0.025f * (8.0f - approachRate); // 2.5% for each AR below 8
+ double approachRateFactor = 1.0;
+ if (Attributes.ApproachRate > 9.0)
+ approachRateFactor += 0.1 * (Attributes.ApproachRate - 9.0); // 10% for each AR above 9
+ else if (Attributes.ApproachRate < 8.0)
+ approachRateFactor += 0.025 * (8.0 - Attributes.ApproachRate); // 2.5% for each AR below 8
value *= approachRateFactor;
if (mods.Any(m => m is ModHidden))
// Hiddens gives nothing on max approach rate, and more the lower it is
- value *= 1.05f + 0.075f * (10.0f - Math.Min(10.0f, approachRate)); // 7.5% for each AR below 10
+ value *= 1.05 + 0.075 * (10.0 - Math.Min(10.0, Attributes.ApproachRate)); // 7.5% for each AR below 10
if (mods.Any(m => m is ModFlashlight))
// Apply length bonus again if flashlight is on simply because it becomes a lot harder on longer maps.
- value *= 1.35f * lengthBonus;
+ value *= 1.35 * lengthBonus;
// Scale the aim value with accuracy _slightly_
- value *= Math.Pow(accuracy(), 5.5f);
+ value *= Math.Pow(accuracy(), 5.5);
// Custom multipliers for NoFail. SpunOut is not applicable.
if (mods.Any(m => m is ModNoFail))
- value *= 0.90f;
+ value *= 0.90;
return value;
}
- private float accuracy() => totalHits() == 0 ? 0 : MathHelper.Clamp((float)totalSuccessfulHits() / totalHits(), 0f, 1f);
+ private float accuracy() => totalHits() == 0 ? 0 : Math.Clamp((float)totalSuccessfulHits() / totalHits(), 0, 1);
private int totalHits() => tinyTicksHit + ticksHit + fruitsHit + misses + tinyTicksMissed;
private int totalSuccessfulHits() => tinyTicksHit + ticksHit + fruitsHit;
private int totalComboHits() => misses + ticksHit + fruitsHit;
diff --git a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
index d146153294..7cd569035b 100644
--- a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
+++ b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
@@ -6,7 +6,6 @@ using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
-using osuTK;
namespace osu.Game.Rulesets.Catch.Difficulty.Skills
{
@@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
if (lastPlayerPosition == null)
lastPlayerPosition = catchCurrent.LastNormalizedPosition;
- float playerPosition = MathHelper.Clamp(
+ float playerPosition = Math.Clamp(
lastPlayerPosition.Value,
catchCurrent.NormalizedPosition - (normalized_hitobject_radius - absolute_player_positioning_error),
catchCurrent.NormalizedPosition + (normalized_hitobject_radius - absolute_player_positioning_error)
diff --git a/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs
index c721ff862a..46e427e1b7 100644
--- a/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs
+++ b/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs
@@ -12,14 +12,14 @@ namespace osu.Game.Rulesets.Catch.MathUtils
{
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
private const uint int_mask = 0x7FFFFFFF;
- private const uint y = 842502087;
- private const uint z = 3579807591;
- private const uint w = 273326509;
- private uint _x, _y = y, _z = z, _w = w;
+ private const uint y_initial = 842502087;
+ private const uint z_initial = 3579807591;
+ private const uint w_initial = 273326509;
+ private uint x, y = y_initial, z = z_initial, w = w_initial;
public FastRandom(int seed)
{
- _x = (uint)seed;
+ x = (uint)seed;
}
public FastRandom()
@@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Catch.MathUtils
/// The random value.
public uint NextUInt()
{
- uint t = _x ^ (_x << 11);
- _x = _y;
- _y = _z;
- _z = _w;
- return _w = _w ^ (_w >> 19) ^ t ^ (t >> 8);
+ uint t = x ^ (x << 11);
+ x = y;
+ y = z;
+ z = w;
+ return w = w ^ (w >> 19) ^ t ^ (t >> 8);
}
///
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 0454bc969d..a47efcc10a 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -1,12 +1,48 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Graphics;
+using osu.Framework.Input;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
+using osu.Game.Rulesets.Catch.Objects;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.UI;
+using osuTK;
namespace osu.Game.Rulesets.Catch.Mods
{
- public class CatchModRelax : ModRelax
+ public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset
{
public override string Description => @"Use the mouse to control the catcher.";
+
+ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset)
+ {
+ drawableRuleset.Cursor.Add(new MouseInputHelper((CatchPlayfield)drawableRuleset.Playfield));
+ }
+
+ private class MouseInputHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition
+ {
+ private readonly CatcherArea.Catcher catcher;
+
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
+
+ public MouseInputHelper(CatchPlayfield playfield)
+ {
+ catcher = playfield.CatcherArea.MovableCatcher;
+ RelativeSizeAxes = Axes.Both;
+ }
+
+ //disable keyboard controls
+ public bool OnPressed(CatchAction action) => true;
+ public bool OnReleased(CatchAction action) => true;
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ catcher.UpdatePosition(e.MousePosition.X / DrawSize.X);
+ return base.OnMouseMove(e);
+ }
+ }
}
}
diff --git a/osu.Game.Rulesets.Catch/Objects/BananaShower.cs b/osu.Game.Rulesets.Catch/Objects/BananaShower.cs
index 6d44e4660e..267e6d12c7 100644
--- a/osu.Game.Rulesets.Catch/Objects/BananaShower.cs
+++ b/osu.Game.Rulesets.Catch/Objects/BananaShower.cs
@@ -27,11 +27,13 @@ namespace osu.Game.Rulesets.Catch.Objects
return;
for (double i = StartTime; i <= EndTime; i += spacing)
+ {
AddNested(new Banana
{
Samples = Samples,
StartTime = i
});
+ }
}
public double EndTime => StartTime + Duration;
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableBananaShower.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableBananaShower.cs
index 42646851d7..ea415e18fa 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableBananaShower.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableBananaShower.cs
@@ -2,35 +2,50 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public class DrawableBananaShower : DrawableCatchHitObject
{
+ private readonly Func> createDrawableRepresentation;
private readonly Container bananaContainer;
public DrawableBananaShower(BananaShower s, Func> createDrawableRepresentation = null)
: base(s)
{
+ this.createDrawableRepresentation = createDrawableRepresentation;
RelativeSizeAxes = Axes.X;
Origin = Anchor.BottomLeft;
X = 0;
AddInternal(bananaContainer = new Container { RelativeSizeAxes = Axes.Both });
-
- foreach (var b in s.NestedHitObjects.Cast())
- AddNested(createDrawableRepresentation?.Invoke(b));
}
- protected override void AddNested(DrawableHitObject h)
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
{
- ((DrawableCatchHitObject)h).CheckPosition = o => CheckPosition?.Invoke(o) ?? false;
- bananaContainer.Add(h);
- base.AddNested(h);
+ base.AddNestedHitObject(hitObject);
+ bananaContainer.Add(hitObject);
+ }
+
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ bananaContainer.Clear();
+ }
+
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case Banana banana:
+ return createDrawableRepresentation?.Invoke(banana)?.With(o => ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
+ }
+
+ return base.CreateNestedHitObject(hitObject);
}
}
}
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs
index dd4a58a5ef..b7c05392f3 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs
@@ -4,8 +4,8 @@
using System;
using osuTK;
using osu.Framework.Graphics;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
@@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
protected override void UpdateStateTransforms(ArmedState state)
{
- var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
+ var endTime = HitObject.GetEndTime();
using (BeginAbsoluteSequence(endTime, true))
{
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs
index 1af77b75fc..958cd19d50 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs
@@ -98,9 +98,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
const float small_pulp = large_pulp_3 / 2;
- Vector2 positionAt(float angle, float distance) => new Vector2(
- distance * (float)Math.Sin(angle * Math.PI / 180),
- distance * (float)Math.Cos(angle * Math.PI / 180));
+ static Vector2 positionAt(float angle, float distance) => new Vector2(
+ distance * MathF.Sin(angle * MathF.PI / 180),
+ distance * MathF.Cos(angle * MathF.PI / 180));
switch (representation)
{
@@ -278,7 +278,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
base.Update();
- border.Alpha = (float)MathHelper.Clamp((HitObject.StartTime - Time.Current) / 500, 0, 1);
+ border.Alpha = (float)Math.Clamp((HitObject.StartTime - Time.Current) / 500, 0, 1);
}
private Color4 colourForRepresentation(FruitVisualRepresentation representation)
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableJuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableJuiceStream.cs
index 9e5e9f6a04..a24821b3ce 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableJuiceStream.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableJuiceStream.cs
@@ -2,38 +2,50 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public class DrawableJuiceStream : DrawableCatchHitObject
{
+ private readonly Func> createDrawableRepresentation;
private readonly Container dropletContainer;
public DrawableJuiceStream(JuiceStream s, Func> createDrawableRepresentation = null)
: base(s)
{
+ this.createDrawableRepresentation = createDrawableRepresentation;
RelativeSizeAxes = Axes.Both;
Origin = Anchor.BottomLeft;
X = 0;
AddInternal(dropletContainer = new Container { RelativeSizeAxes = Axes.Both, });
-
- foreach (var o in s.NestedHitObjects.Cast())
- AddNested(createDrawableRepresentation?.Invoke(o));
}
- protected override void AddNested(DrawableHitObject h)
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
{
- var catchObject = (DrawableCatchHitObject)h;
+ base.AddNestedHitObject(hitObject);
+ dropletContainer.Add(hitObject);
+ }
- catchObject.CheckPosition = o => CheckPosition?.Invoke(o) ?? false;
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ dropletContainer.Clear();
+ }
- dropletContainer.Add(h);
- base.AddNested(h);
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case CatchHitObject catchObject:
+ return createDrawableRepresentation?.Invoke(catchObject)?.With(o => ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
+ }
+
+ return base.CreateNestedHitObject(hitObject);
}
}
}
diff --git a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
index 0952e8981a..d5d99640af 100644
--- a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
+++ b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
@@ -116,17 +116,27 @@ namespace osu.Game.Rulesets.Catch.Objects
public double Duration => EndTime - StartTime;
- private SliderPath path;
+ private readonly SliderPath path = new SliderPath();
public SliderPath Path
{
get => path;
- set => path = value;
+ set
+ {
+ path.ControlPoints.Clear();
+ path.ExpectedDistance.Value = null;
+
+ if (value != null)
+ {
+ path.ControlPoints.AddRange(value.ControlPoints);
+ path.ExpectedDistance.Value = value.ExpectedDistance.Value;
+ }
+ }
}
public double Distance => Path.Distance;
- public List> NodeSamples { get; set; } = new List>();
+ public List> NodeSamples { get; set; } = new List>();
public double? LegacyLastTickOffset { get; set; }
}
diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
index b6d8cf9cbe..589503c35b 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
@@ -10,6 +10,7 @@ using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
+using osuTK;
namespace osu.Game.Rulesets.Catch.UI
{
@@ -19,6 +20,8 @@ namespace osu.Game.Rulesets.Catch.UI
internal readonly CatcherArea CatcherArea;
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || CatcherArea.ReceivePositionalInputAt(screenSpacePos);
+
public CatchPlayfield(BeatmapDifficulty difficulty, Func> createDrawableRepresentation)
{
Container explodingFruitContainer;
diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
index 56c8b33e02..2d6ce02e45 100644
--- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
@@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Catch.UI
var additive = createCatcherSprite();
additive.Anchor = Anchor;
- additive.OriginPosition = additive.OriginPosition + new Vector2(DrawWidth / 2, 0); // also temporary to align sprite correctly.
+ additive.OriginPosition += new Vector2(DrawWidth / 2, 0); // also temporary to align sprite correctly.
additive.Position = Position;
additive.Scale = Scale;
additive.Colour = HyperDashing ? Color4.Red : Color4.White;
@@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.Y -= RNG.NextSingle() * diff;
}
- fruit.X = MathHelper.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
+ fruit.X = Math.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
caughtFruit.Add(fruit);
}
@@ -377,8 +377,7 @@ namespace osu.Game.Rulesets.Catch.UI
double dashModifier = Dashing ? 1 : 0.5;
double speed = BASE_SPEED * dashModifier * hyperDashModifier;
- Scale = new Vector2(Math.Abs(Scale.X) * direction, Scale.Y);
- X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * speed, 0, 1);
+ UpdatePosition((float)(X + direction * Clock.ElapsedFrameTime * speed));
// Correct overshooting.
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||
@@ -452,6 +451,17 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.LifetimeStart = Time.Current;
fruit.Expire();
}
+
+ public void UpdatePosition(float position)
+ {
+ position = Math.Clamp(position, 0, 1);
+
+ if (position == X)
+ return;
+
+ Scale = new Vector2(Math.Abs(Scale.X) * (position > X ? 1 : -1), Scale.Y);
+ X = position;
+ }
}
}
}
diff --git a/osu.Game.Rulesets.Catch/UI/CatcherSprite.cs b/osu.Game.Rulesets.Catch/UI/CatcherSprite.cs
index e3c6c93d01..025fa9c56e 100644
--- a/osu.Game.Rulesets.Catch/UI/CatcherSprite.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatcherSprite.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.UI
[BackgroundDependencyLoader]
private void load()
{
- InternalChild = new SkinnableSprite("Gameplay/catch/fruit-catcher-idle")
+ InternalChild = new SkinnableSprite("Gameplay/catch/fruit-catcher-idle", confineMode: ConfineMode.ScaleDownToFit)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
diff --git a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj
index 883cac67d1..b19affbf9f 100644
--- a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj
+++ b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj
@@ -1,9 +1,7 @@
-
- netstandard2.0
+ netstandard2.1
Library
- AnyCPU
true
catch the fruit. to the beat.
diff --git a/osu.Game.Rulesets.Mania.Tests.Android/Properties/AndroidManifest.xml b/osu.Game.Rulesets.Mania.Tests.Android/Properties/AndroidManifest.xml
index e6728c801d..de7935b2ef 100644
--- a/osu.Game.Rulesets.Mania.Tests.Android/Properties/AndroidManifest.xml
+++ b/osu.Game.Rulesets.Mania.Tests.Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania.Tests.iOS/osu.Game.Rulesets.Mania.Tests.iOS.csproj b/osu.Game.Rulesets.Mania.Tests.iOS/osu.Game.Rulesets.Mania.Tests.iOS.csproj
index 58c2e2aa5a..88ad484bc1 100644
--- a/osu.Game.Rulesets.Mania.Tests.iOS/osu.Game.Rulesets.Mania.Tests.iOS.csproj
+++ b/osu.Game.Rulesets.Mania.Tests.iOS/osu.Game.Rulesets.Mania.Tests.iOS.csproj
@@ -1,6 +1,5 @@
-
+
-
Debug
iPhoneSimulator
@@ -33,5 +32,4 @@
-
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs
index 6f10540973..12865385b6 100644
--- a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs
+++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs
@@ -9,7 +9,6 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Mania.Tests
@@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Mania.Tests
yield return new ConvertValue
{
StartTime = hitObject.StartTime,
- EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
+ EndTime = hitObject.GetEndTime(),
Column = ((ManiaHitObject)hitObject).Column
};
}
diff --git a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
index 30511d672d..8fc4dbfe72 100644
--- a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
+++ b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
index e10602312e..9069c09ae4 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
@@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
if (TargetColumns >= 10)
{
- TargetColumns = TargetColumns / 2;
+ TargetColumns /= 2;
Dual = true;
}
}
@@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
{
BeatmapDifficulty difficulty = original.BeatmapInfo.BaseDifficulty;
- int seed = (int)Math.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)Math.Round(difficulty.ApproachRate);
+ int seed = (int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate);
Random = new FastRandom(seed);
return base.ConvertBeatmap(original);
@@ -156,37 +156,44 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
/// The hit objects generated.
private IEnumerable generateConverted(HitObject original, IBeatmap originalBeatmap)
{
- var endTimeData = original as IHasEndTime;
- var distanceData = original as IHasDistance;
- var positionData = original as IHasPosition;
-
Patterns.PatternGenerator conversion = null;
- if (distanceData != null)
+ switch (original)
{
- var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
- conversion = generator;
-
- for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
+ case IHasDistance _:
{
- recordNote(time, positionData?.Position ?? Vector2.Zero);
- computeDensity(time);
+ var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
+ conversion = generator;
+
+ var positionData = original as IHasPosition;
+
+ for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
+ {
+ recordNote(time, positionData?.Position ?? Vector2.Zero);
+ computeDensity(time);
+ }
+
+ break;
}
- }
- else if (endTimeData != null)
- {
- conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
- recordNote(endTimeData.EndTime, new Vector2(256, 192));
- computeDensity(endTimeData.EndTime);
- }
- else if (positionData != null)
- {
- computeDensity(original.StartTime);
+ case IHasEndTime endTimeData:
+ {
+ conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
- conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);
+ recordNote(endTimeData.EndTime, new Vector2(256, 192));
+ computeDensity(endTimeData.EndTime);
+ break;
+ }
- recordNote(original.StartTime, positionData.Position);
+ case IHasPosition positionData:
+ {
+ computeDensity(original.StartTime);
+
+ conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);
+
+ recordNote(original.StartTime, positionData.Position);
+ break;
+ }
}
if (conversion == null)
@@ -219,14 +226,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
private Pattern generate()
{
- var endTimeData = HitObject as IHasEndTime;
var positionData = HitObject as IHasXPosition;
int column = GetColumn(positionData?.X ?? 0);
var pattern = new Pattern();
- if (endTimeData != null)
+ if (HitObject is IHasEndTime endTimeData)
{
pattern.Add(new HoldNote
{
@@ -237,7 +243,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) },
});
}
- else if (positionData != null)
+ else if (HitObject is IHasXPosition)
{
pattern.Add(new Note
{
@@ -255,11 +261,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
///
/// The time to retrieve the sample info list from.
///
- private List sampleInfoListAt(double time)
+ private IList sampleInfoListAt(double time)
{
- var curveData = HitObject as IHasCurve;
-
- if (curveData == null)
+ if (!(HitObject is IHasCurve curveData))
return HitObject.Samples;
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
index ea418eedb4..9565ac8994 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
@@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
foreach (var obj in originalPattern.HitObjects)
{
- if (!Precision.AlmostEquals(EndTime, (obj as IHasEndTime)?.EndTime ?? obj.StartTime))
+ if (!Precision.AlmostEquals(EndTime, obj.GetEndTime()))
intermediatePattern.Add(obj);
else
endTimePattern.Add(obj);
@@ -364,7 +364,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
break;
}
- bool isDoubleSample(HitSampleInfo sample) => sample.Name == HitSampleInfo.HIT_CLAP || sample.Name == HitSampleInfo.HIT_FINISH;
+ static bool isDoubleSample(HitSampleInfo sample) => sample.Name == HitSampleInfo.HIT_CLAP || sample.Name == HitSampleInfo.HIT_FINISH;
bool canGenerateTwoNotes = !convertType.HasFlag(PatternType.LowProbability);
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample);
@@ -472,11 +472,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
///
/// The time to retrieve the sample info list from.
///
- private List sampleInfoListAt(double time)
+ private IList sampleInfoListAt(double time)
{
- var curveData = HitObject as IHasCurve;
-
- if (curveData == null)
+ if (!(HitObject is IHasCurve curveData))
return HitObject.Samples;
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs
index decd159ee9..84f950997d 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs
@@ -12,6 +12,7 @@ using osu.Game.Rulesets.Mania.MathUtils;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
+using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
{
@@ -88,15 +89,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
public override IEnumerable Generate()
{
- yield return generate();
- }
-
- private Pattern generate()
- {
- var pattern = new Pattern();
-
- try
+ Pattern generateCore()
{
+ var pattern = new Pattern();
+
if (TotalColumns == 1)
{
addToPattern(pattern, 0);
@@ -109,8 +105,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
{
// Generate a new pattern by copying the last hit objects in reverse-column order
for (int i = RandomStart; i < TotalColumns; i++)
+ {
if (PreviousPattern.ColumnHasObject(i))
addToPattern(pattern, RandomStart + TotalColumns - i - 1);
+ }
return pattern;
}
@@ -132,8 +130,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
{
// Generate a new pattern by placing on the already filled columns
for (int i = RandomStart; i < TotalColumns; i++)
+ {
if (PreviousPattern.ColumnHasObject(i))
addToPattern(pattern, i);
+ }
return pattern;
}
@@ -164,54 +164,56 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
}
if (convertType.HasFlag(PatternType.KeepSingle))
- return pattern = generateRandomNotes(1);
+ return generateRandomNotes(1);
if (convertType.HasFlag(PatternType.Mirror))
{
if (ConversionDifficulty > 6.5)
- return pattern = generateRandomPatternWithMirrored(0.12, 0.38, 0.12);
+ return generateRandomPatternWithMirrored(0.12, 0.38, 0.12);
if (ConversionDifficulty > 4)
- return pattern = generateRandomPatternWithMirrored(0.12, 0.17, 0);
+ return generateRandomPatternWithMirrored(0.12, 0.17, 0);
- return pattern = generateRandomPatternWithMirrored(0.12, 0, 0);
+ return generateRandomPatternWithMirrored(0.12, 0, 0);
}
if (ConversionDifficulty > 6.5)
{
if (convertType.HasFlag(PatternType.LowProbability))
- return pattern = generateRandomPattern(0.78, 0.42, 0, 0);
+ return generateRandomPattern(0.78, 0.42, 0, 0);
- return pattern = generateRandomPattern(1, 0.62, 0, 0);
+ return generateRandomPattern(1, 0.62, 0, 0);
}
if (ConversionDifficulty > 4)
{
if (convertType.HasFlag(PatternType.LowProbability))
- return pattern = generateRandomPattern(0.35, 0.08, 0, 0);
+ return generateRandomPattern(0.35, 0.08, 0, 0);
- return pattern = generateRandomPattern(0.52, 0.15, 0, 0);
+ return generateRandomPattern(0.52, 0.15, 0, 0);
}
if (ConversionDifficulty > 2)
{
if (convertType.HasFlag(PatternType.LowProbability))
- return pattern = generateRandomPattern(0.18, 0, 0, 0);
+ return generateRandomPattern(0.18, 0, 0, 0);
- return pattern = generateRandomPattern(0.45, 0, 0, 0);
+ return generateRandomPattern(0.45, 0, 0, 0);
}
- return pattern = generateRandomPattern(0, 0, 0, 0);
+ return generateRandomPattern(0, 0, 0, 0);
}
- finally
+
+ var p = generateCore();
+
+ foreach (var obj in p.HitObjects)
{
- foreach (var obj in pattern.HitObjects)
- {
- if (convertType.HasFlag(PatternType.Stair) && obj.Column == TotalColumns - 1)
- StairType = PatternType.ReverseStair;
- if (convertType.HasFlag(PatternType.ReverseStair) && obj.Column == RandomStart)
- StairType = PatternType.Stair;
- }
+ if (convertType.HasFlag(PatternType.Stair) && obj.Column == TotalColumns - 1)
+ StairType = PatternType.ReverseStair;
+ if (convertType.HasFlag(PatternType.ReverseStair) && obj.Column == RandomStart)
+ StairType = PatternType.Stair;
}
+
+ return p.Yield();
}
///
@@ -299,8 +301,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
var pattern = new Pattern();
- bool addToCentre;
- int noteCount = getRandomNoteCountMirrored(centreProbability, p2, p3, out addToCentre);
+ int noteCount = getRandomNoteCountMirrored(centreProbability, p2, p3, out var addToCentre);
int columnLimit = (TotalColumns % 2 == 0 ? TotalColumns : TotalColumns - 1) / 2;
int nextColumn = GetRandomColumn(upperBound: columnLimit);
@@ -380,8 +381,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// The amount of notes to be generated. The note to be added to the centre column will NOT be part of this count.
private int getRandomNoteCountMirrored(double centreProbability, double p2, double p3, out bool addToCentre)
{
- addToCentre = false;
-
switch (TotalColumns)
{
case 2:
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs
index fba52dfc32..fb58d805a9 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs
@@ -7,7 +7,6 @@ using JetBrains.Annotations;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.MathUtils;
using osu.Game.Rulesets.Objects;
-using osuTK;
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
{
@@ -54,11 +53,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
if (allowSpecial && TotalColumns == 8)
{
const float local_x_divisor = 512f / 7;
- return MathHelper.Clamp((int)Math.Floor(position / local_x_divisor), 0, 6) + 1;
+ return Math.Clamp((int)MathF.Floor(position / local_x_divisor), 0, 6) + 1;
}
float localXDivisor = 512f / TotalColumns;
- return MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, TotalColumns - 1);
+ return Math.Clamp((int)MathF.Floor(position / localXDivisor), 0, TotalColumns - 1);
}
///
@@ -113,7 +112,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
drainTime = 10000;
BeatmapDifficulty difficulty = OriginalBeatmap.BeatmapInfo.BaseDifficulty;
- conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + (double)OriginalBeatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15;
+ conversionDifficulty = ((difficulty.DrainRate + Math.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + (double)OriginalBeatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15;
conversionDifficulty = Math.Min(conversionDifficulty.Value, 12);
return conversionDifficulty.Value;
@@ -139,7 +138,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// A function to retrieve the next column. If null, a randomisation scheme will be used.
/// A function to perform additional validation checks to determine if a column is a valid candidate for a .
/// The minimum column index. If null, is used.
- /// The maximum column index. If null, is used.
+ /// The maximum column index. If null, TotalColumns is used.
/// A list of patterns for which the validity of a column should be checked against.
/// A column is not a valid candidate if a occupies the same column in any of the patterns.
/// A column which has passed the check and for which there are no
@@ -148,9 +147,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
protected int FindAvailableColumn(int initialColumn, int? lowerBound = null, int? upperBound = null, Func nextColumn = null, [InstantHandle] Func validation = null,
params Pattern[] patterns)
{
- lowerBound = lowerBound ?? RandomStart;
- upperBound = upperBound ?? TotalColumns;
- nextColumn = nextColumn ?? (_ => GetRandomColumn(lowerBound, upperBound));
+ lowerBound ??= RandomStart;
+ upperBound ??= TotalColumns;
+ nextColumn ??= (_ => GetRandomColumn(lowerBound, upperBound));
// Check for the initial column
if (isValid(initialColumn))
@@ -184,7 +183,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// Returns a random column index in the range [, ).
///
/// The minimum column index. If null, is used.
- /// The maximum column index. If null, is used.
+ /// The maximum column index. If null, is used.
protected int GetRandomColumn(int? lowerBound = null, int? upperBound = null) => Random.Next(lowerBound ?? RandomStart, upperBound ?? TotalColumns);
///
diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs
index b99bddee96..3f7a2baedd 100644
--- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs
+++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs
@@ -37,12 +37,12 @@ namespace osu.Game.Rulesets.Mania.Difficulty
{
mods = Score.Mods;
scaledScore = Score.TotalScore;
- countPerfect = Convert.ToInt32(Score.Statistics[HitResult.Perfect]);
- countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
- countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
- countOk = Convert.ToInt32(Score.Statistics[HitResult.Ok]);
- countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
- countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
+ countPerfect = Score.Statistics[HitResult.Perfect];
+ countGreat = Score.Statistics[HitResult.Great];
+ countGood = Score.Statistics[HitResult.Good];
+ countOk = Score.Statistics[HitResult.Ok];
+ countMeh = Score.Statistics[HitResult.Meh];
+ countMiss = Score.Statistics[HitResult.Miss];
if (mods.Any(m => !m.Ranked))
return 0;
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteNoteSelectionBlueprint.cs
new file mode 100644
index 0000000000..acce41db6f
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteNoteSelectionBlueprint.cs
@@ -0,0 +1,45 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
+using osu.Game.Rulesets.Mania.Objects.Drawables;
+
+namespace osu.Game.Rulesets.Mania.Edit.Blueprints
+{
+ public class HoldNoteNoteSelectionBlueprint : ManiaSelectionBlueprint
+ {
+ protected new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
+
+ private readonly HoldNotePosition position;
+
+ public HoldNoteNoteSelectionBlueprint(DrawableHoldNote holdNote, HoldNotePosition position)
+ : base(holdNote)
+ {
+ this.position = position;
+ InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
+
+ Select();
+ }
+
+ protected override void Update()
+ {
+ base.Update();
+
+ // Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
+ if (DrawableObject.IsLoaded)
+ {
+ DrawableNote note = position == HoldNotePosition.Start ? DrawableObject.Head : DrawableObject.Tail;
+
+ Anchor = note.Anchor;
+ Origin = note.Origin;
+
+ Size = note.DrawSize;
+ Position = note.DrawPosition;
+ }
+ }
+
+ // Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
+ public override bool HandlePositionalInput => false;
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePosition.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePosition.cs
new file mode 100644
index 0000000000..219dad566d
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePosition.cs
@@ -0,0 +1,11 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Rulesets.Mania.Edit.Blueprints
+{
+ public enum HoldNotePosition
+ {
+ Start,
+ End
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
index d64c5dbc6a..56c0b671a0 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
@@ -16,69 +16,57 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
{
- public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
+ public new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
private readonly IBindable direction = new Bindable();
- private readonly BodyPiece body;
+ [Resolved]
+ private OsuColour colours { get; set; }
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
: base(hold)
{
- InternalChildren = new Drawable[]
- {
- new HoldNoteNoteSelectionBlueprint(hold.Head),
- new HoldNoteNoteSelectionBlueprint(hold.Tail),
- body = new BodyPiece
- {
- AccentColour = Color4.Transparent
- },
- };
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours, IScrollingInfo scrollingInfo)
+ private void load(IScrollingInfo scrollingInfo)
{
- body.BorderColour = colours.Yellow;
-
direction.BindTo(scrollingInfo.Direction);
}
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ InternalChildren = new Drawable[]
+ {
+ new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.Start),
+ new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.End),
+ new BodyPiece
+ {
+ AccentColour = Color4.Transparent,
+ BorderColour = colours.Yellow
+ },
+ };
+ }
+
protected override void Update()
{
base.Update();
- Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
+ // Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
+ if (DrawableObject.IsLoaded)
+ {
+ Size = DrawableObject.DrawSize + new Vector2(0, DrawableObject.Tail.DrawHeight);
- // This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
- // When scrolling upwards our origin is already at the top of the head note (which is the intended location),
- // but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
- if (direction.Value == ScrollingDirection.Down)
- Y -= HitObject.Tail.DrawHeight;
+ // This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
+ // When scrolling upwards our origin is already at the top of the head note (which is the intended location),
+ // but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
+ if (direction.Value == ScrollingDirection.Down)
+ Y -= DrawableObject.Tail.DrawHeight;
+ }
}
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
-
- private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
- {
- public HoldNoteNoteSelectionBlueprint(DrawableNote note)
- : base(note)
- {
- Select();
- }
-
- protected override void Update()
- {
- base.Update();
-
- Anchor = HitObject.Anchor;
- Origin = HitObject.Origin;
-
- Position = HitObject.DrawPosition;
- }
-
- // Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
- public override bool HandlePositionalInput => false;
- }
}
}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
index 3142f22fcd..b28d8bb0e6 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
@@ -49,10 +49,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
if (Column == null)
return base.OnMouseDown(e);
- HitObject.StartTime = TimeAt(e.ScreenSpaceMousePosition);
HitObject.Column = Column.Index;
-
- BeginPlacement();
+ BeginPlacement(TimeAt(e.ScreenSpaceMousePosition));
return true;
}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs
index cc50459a0c..3bd7fb2d49 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs
@@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
public Vector2 ScreenSpaceDragPosition { get; private set; }
public Vector2 DragPosition { get; private set; }
- public new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject;
+ public new DrawableManiaHitObject DrawableObject => (DrawableManiaHitObject)base.DrawableObject;
protected IClock EditorClock { get; private set; }
@@ -28,8 +28,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
[Resolved]
private IManiaHitObjectComposer composer { get; set; }
- public ManiaSelectionBlueprint(DrawableHitObject hitObject)
- : base(hitObject)
+ public ManiaSelectionBlueprint(DrawableHitObject drawableObject)
+ : base(drawableObject)
{
RelativeSizeAxes = Axes.None;
}
@@ -44,13 +44,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
base.Update();
- Position = Parent.ToLocalSpace(HitObject.ToScreenSpace(Vector2.Zero));
+ Position = Parent.ToLocalSpace(DrawableObject.ToScreenSpace(Vector2.Zero));
}
protected override bool OnMouseDown(MouseDownEvent e)
{
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
- DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
+ DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);
return base.OnMouseDown(e);
}
@@ -60,20 +60,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
var result = base.OnDrag(e);
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
- DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
+ DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);
return result;
}
public override void Show()
{
- HitObject.AlwaysAlive = true;
+ DrawableObject.AlwaysAlive = true;
base.Show();
}
public override void Hide()
{
- HitObject.AlwaysAlive = false;
+ DrawableObject.AlwaysAlive = false;
base.Hide();
}
}
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs
index d345b14e84..2bff33c4cf 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs
@@ -19,7 +19,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
base.Update();
- Size = HitObject.DrawSize;
+ // Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
+ if (DrawableObject.IsLoaded)
+ Size = DrawableObject.DrawSize;
}
}
}
diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs
index f576c43e52..618af3e772 100644
--- a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs
+++ b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Timing;
@@ -9,7 +10,6 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit.Compose.Components;
-using osuTK;
namespace osu.Game.Rulesets.Mania.Edit
{
@@ -29,16 +29,16 @@ namespace osu.Game.Rulesets.Mania.Edit
editorClock = clock;
}
- public override void HandleMovement(MoveSelectionEvent moveEvent)
+ public override bool HandleMovement(MoveSelectionEvent moveEvent)
{
var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint;
- int lastColumn = maniaBlueprint.HitObject.HitObject.Column;
+ int lastColumn = maniaBlueprint.DrawableObject.HitObject.Column;
adjustOrigins(maniaBlueprint);
performDragMovement(moveEvent);
performColumnMovement(lastColumn, moveEvent);
- base.HandleMovement(moveEvent);
+ return true;
}
///
@@ -48,41 +48,44 @@ namespace osu.Game.Rulesets.Mania.Edit
/// The that received the drag event.
private void adjustOrigins(ManiaSelectionBlueprint reference)
{
- var referenceParent = (HitObjectContainer)reference.HitObject.Parent;
+ var referenceParent = (HitObjectContainer)reference.DrawableObject.Parent;
- float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.HitObject.OriginPosition.Y;
+ float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.DrawableObject.OriginPosition.Y;
float targetPosition = referenceParent.ToLocalSpace(reference.ScreenSpaceDragPosition).Y - offsetFromReferenceOrigin;
// Flip the vertical coordinate space when scrolling downwards
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
- targetPosition = targetPosition - referenceParent.DrawHeight;
+ targetPosition -= referenceParent.DrawHeight;
- float movementDelta = targetPosition - reference.HitObject.Position.Y;
+ float movementDelta = targetPosition - reference.DrawableObject.Position.Y;
foreach (var b in SelectedBlueprints.OfType())
- b.HitObject.Y += movementDelta;
+ b.DrawableObject.Y += movementDelta;
}
private void performDragMovement(MoveSelectionEvent moveEvent)
{
+ float delta = moveEvent.InstantDelta.Y;
+
+ // When scrolling downwards the anchor position is at the bottom of the screen, however the movement event assumes the anchor is at the top of the screen.
+ // This causes the delta to assume a positive hitobject position, and which can be corrected for by subtracting the parent height.
+ if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
+ delta -= moveEvent.Blueprint.DrawableObject.Parent.DrawHeight;
+
foreach (var b in SelectedBlueprints)
{
- var hitObject = b.HitObject;
-
+ var hitObject = b.DrawableObject;
var objectParent = (HitObjectContainer)hitObject.Parent;
- // Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
- // without the position having been updated by the parenting ScrollingHitObjectContainer
- hitObject.Y += moveEvent.InstantDelta.Y;
+ // StartTime could be used to adjust the position if only one movement event was received per frame.
+ // However this is not the case and ScrollingHitObjectContainer performs movement in UpdateAfterChildren() so the position must also be updated to be valid for further movement events
+ hitObject.Y += delta;
- float targetPosition;
+ float targetPosition = hitObject.Position.Y;
- // If we're scrolling downwards, a position of 0 is actually further away from the hit target
- // so we need to flip the vertical coordinate in the hitobject container's space
+ // The scrolling algorithm always assumes an anchor at the top of the screen, so the position must be flipped when scrolling downwards to reflect a top anchor
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
- targetPosition = -hitObject.Position.Y;
- else
- targetPosition = hitObject.Position.Y;
+ targetPosition = -targetPosition;
objectParent.Remove(hitObject);
@@ -116,7 +119,7 @@ namespace osu.Game.Rulesets.Mania.Edit
maxColumn = obj.Column;
}
- columnDelta = MathHelper.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
+ columnDelta = Math.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
foreach (var obj in SelectedHitObjects.OfType())
obj.Column += columnDelta;
diff --git a/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs
index 30b0f09a94..ff8882124f 100644
--- a/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs
@@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
{
public abstract class ManiaSelectionBlueprint : SelectionBlueprint
{
- protected ManiaSelectionBlueprint(DrawableHitObject hitObject)
- : base(hitObject)
+ protected ManiaSelectionBlueprint(DrawableHitObject drawableObject)
+ : base(drawableObject)
{
RelativeSizeAxes = Axes.None;
}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
index c5c157608f..87b9633c80 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
@@ -2,13 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
-using System.Linq;
using osu.Framework.Bindables;
-using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI.Scrolling;
@@ -22,8 +21,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
public override bool DisplayResult => false;
- public readonly DrawableNote Head;
- public readonly DrawableNote Tail;
+ public DrawableNote Head => headContainer.Child;
+ public DrawableNote Tail => tailContainer.Child;
+
+ private readonly Container headContainer;
+ private readonly Container tailContainer;
+ private readonly Container tickContainer;
private readonly BodyPiece bodyPiece;
@@ -40,50 +43,81 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
public DrawableHoldNote(HoldNote hitObject)
: base(hitObject)
{
- Container tickContainer;
RelativeSizeAxes = Axes.X;
AddRangeInternal(new Drawable[]
{
- bodyPiece = new BodyPiece
- {
- RelativeSizeAxes = Axes.X,
- },
- tickContainer = new Container
- {
- RelativeSizeAxes = Axes.Both,
- ChildrenEnumerable = HitObject.NestedHitObjects.OfType().Select(tick => new DrawableHoldNoteTick(tick)
- {
- HoldStartTime = () => holdStartTime
- })
- },
- Head = new DrawableHeadNote(this)
- {
- Anchor = Anchor.TopCentre,
- Origin = Anchor.TopCentre
- },
- Tail = new DrawableTailNote(this)
- {
- Anchor = Anchor.TopCentre,
- Origin = Anchor.TopCentre
- }
+ bodyPiece = new BodyPiece { RelativeSizeAxes = Axes.X },
+ tickContainer = new Container { RelativeSizeAxes = Axes.Both },
+ headContainer = new Container { RelativeSizeAxes = Axes.Both },
+ tailContainer = new Container { RelativeSizeAxes = Axes.Both },
});
- foreach (var tick in tickContainer)
- AddNested(tick);
-
- AddNested(Head);
- AddNested(Tail);
-
AccentColour.BindValueChanged(colour =>
{
bodyPiece.AccentColour = colour.NewValue;
- Head.AccentColour.Value = colour.NewValue;
- Tail.AccentColour.Value = colour.NewValue;
- tickContainer.ForEach(t => t.AccentColour.Value = colour.NewValue);
}, true);
}
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
+ {
+ base.AddNestedHitObject(hitObject);
+
+ switch (hitObject)
+ {
+ case DrawableHeadNote head:
+ headContainer.Child = head;
+ break;
+
+ case DrawableTailNote tail:
+ tailContainer.Child = tail;
+ break;
+
+ case DrawableHoldNoteTick tick:
+ tickContainer.Add(tick);
+ break;
+ }
+ }
+
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ headContainer.Clear();
+ tailContainer.Clear();
+ tickContainer.Clear();
+ }
+
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case TailNote _:
+ return new DrawableTailNote(this)
+ {
+ Anchor = Anchor.TopCentre,
+ Origin = Anchor.TopCentre,
+ AccentColour = { BindTarget = AccentColour }
+ };
+
+ case Note _:
+ return new DrawableHeadNote(this)
+ {
+ Anchor = Anchor.TopCentre,
+ Origin = Anchor.TopCentre,
+ AccentColour = { BindTarget = AccentColour }
+ };
+
+ case HoldNoteTick tick:
+ return new DrawableHoldNoteTick(tick)
+ {
+ HoldStartTime = () => holdStartTime,
+ AccentColour = { BindTarget = AccentColour }
+ };
+ }
+
+ return base.CreateNestedHitObject(hitObject);
+ }
+
protected override void OnDirectionChanged(ValueChangedEvent e)
{
base.OnDirectionChanged(e);
diff --git a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs
index 2b336ca16d..483327d5b3 100644
--- a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs
@@ -6,7 +6,6 @@ using System.Linq;
using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Mania.Replays
@@ -84,7 +83,7 @@ namespace osu.Game.Rulesets.Mania.Replays
var currentObject = Beatmap.HitObjects[i];
var nextObjectInColumn = GetNextObject(i); // Get the next object that requires pressing the same button
- double endTime = (currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime;
+ double endTime = currentObject.GetEndTime();
bool canDelayKeyUp = nextObjectInColumn == null ||
nextObjectInColumn.StartTime > endTime + RELEASE_DELAY;
diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
index 5ab07416a6..08f6049782 100644
--- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
+++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
@@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Mania.UI
foreach (var stage in stages)
{
- sum = sum + stage.Columns.Count;
+ sum += stage.Columns.Count;
if (sum > column)
return stage;
}
diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
index a086da0565..07ef1022ae 100644
--- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
+++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj
@@ -1,9 +1,7 @@
-
- netstandard2.0
+ netstandard2.1
Library
- AnyCPU
true
smash the keys. to the beat.
diff --git a/osu.Game.Rulesets.Osu.Tests.Android/Properties/AndroidManifest.xml b/osu.Game.Rulesets.Osu.Tests.Android/Properties/AndroidManifest.xml
index aad907b241..3ce17ccc27 100644
--- a/osu.Game.Rulesets.Osu.Tests.Android/Properties/AndroidManifest.xml
+++ b/osu.Game.Rulesets.Osu.Tests.Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Osu.Tests.iOS/osu.Game.Rulesets.Osu.Tests.iOS.csproj b/osu.Game.Rulesets.Osu.Tests.iOS/osu.Game.Rulesets.Osu.Tests.iOS.csproj
index c7787bd162..545abcec6c 100644
--- a/osu.Game.Rulesets.Osu.Tests.iOS/osu.Game.Rulesets.Osu.Tests.iOS.csproj
+++ b/osu.Game.Rulesets.Osu.Tests.iOS/osu.Game.Rulesets.Osu.Tests.iOS.csproj
@@ -1,6 +1,5 @@
-
+
-
Debug
iPhoneSimulator
@@ -33,5 +32,4 @@
-
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs
index e9fdf924c3..450f7de6d2 100644
--- a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs
+++ b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Beatmaps;
@@ -41,10 +40,10 @@ namespace osu.Game.Rulesets.Osu.Tests
break;
}
- ConvertValue createConvertValue(OsuHitObject obj) => new ConvertValue
+ static ConvertValue createConvertValue(OsuHitObject obj) => new ConvertValue
{
StartTime = obj.StartTime,
- EndTime = (obj as IHasEndTime)?.EndTime ?? obj.StartTime,
+ EndTime = obj.GetEndTime(),
X = obj.StackedPosition.X,
Y = obj.StackedPosition.Y
};
diff --git a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
index 693faee3b7..85a41137d4 100644
--- a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
+++ b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
@@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
- [TestCase(6.931145117263422, "diffcalc-test")]
+ [TestCase(6.9311451172608853d, "diffcalc-test")]
[TestCase(1.0736587013228804d, "zero-length-sliders")]
public void Test(double expected, string name)
=> base.Test(expected, name);
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs
index 685a51d208..46769f65fe 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs
@@ -101,7 +101,11 @@ namespace osu.Game.Rulesets.Osu.Tests
public IBindable GetConfig(TLookup lookup) => throw new NotImplementedException();
- public event Action SourceChanged;
+ public event Action SourceChanged
+ {
+ add { }
+ remove { }
+ }
}
private class MovingCursorInputManager : ManualInputManager
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
index 433ec6bd25..ac627aa23e 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
@@ -24,12 +24,14 @@ namespace osu.Game.Rulesets.Osu.Tests
public TestSceneDrawableJudgement()
{
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType().Skip(1))
+ {
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
new DrawableOsuJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}));
+ }
}
}
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneFollowPoints.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneFollowPoints.cs
new file mode 100644
index 0000000000..94ca2d4cd1
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneFollowPoints.cs
@@ -0,0 +1,230 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
+using osu.Game.Tests.Visual;
+using osuTK;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneFollowPoints : OsuTestScene
+ {
+ private Container hitObjectContainer;
+ private FollowPointRenderer followPointRenderer;
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ Children = new Drawable[]
+ {
+ hitObjectContainer = new TestHitObjectContainer { RelativeSizeAxes = Axes.Both },
+ followPointRenderer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both }
+ };
+ });
+
+ [Test]
+ public void TestAddObject()
+ {
+ addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } });
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestRemoveObject()
+ {
+ addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } });
+
+ removeObjectStep(() => getObject(0));
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestAddMultipleObjects()
+ {
+ addMultipleObjectsStep();
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestRemoveEndObject()
+ {
+ addMultipleObjectsStep();
+
+ removeObjectStep(() => getObject(4));
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestRemoveStartObject()
+ {
+ addMultipleObjectsStep();
+
+ removeObjectStep(() => getObject(0));
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestRemoveMiddleObject()
+ {
+ addMultipleObjectsStep();
+
+ removeObjectStep(() => getObject(2));
+
+ assertGroups();
+ }
+
+ [Test]
+ public void TestMoveObject()
+ {
+ addMultipleObjectsStep();
+
+ AddStep("move hitobject", () => getObject(2).HitObject.Position = new Vector2(300, 100));
+
+ assertGroups();
+ }
+
+ [TestCase(0, 0)] // Start -> Start
+ [TestCase(0, 2)] // Start -> Middle
+ [TestCase(0, 5)] // Start -> End
+ [TestCase(2, 0)] // Middle -> Start
+ [TestCase(1, 3)] // Middle -> Middle (forwards)
+ [TestCase(3, 1)] // Middle -> Middle (backwards)
+ [TestCase(4, 0)] // End -> Start
+ [TestCase(4, 2)] // End -> Middle
+ [TestCase(4, 4)] // End -> End
+ public void TestReorderObjects(int startIndex, int endIndex)
+ {
+ addMultipleObjectsStep();
+
+ reorderObjectStep(startIndex, endIndex);
+
+ assertGroups();
+ }
+
+ private void addMultipleObjectsStep() => addObjectsStep(() => new OsuHitObject[]
+ {
+ new HitCircle { Position = new Vector2(100, 100) },
+ new HitCircle { Position = new Vector2(200, 200) },
+ new HitCircle { Position = new Vector2(300, 300) },
+ new HitCircle { Position = new Vector2(400, 400) },
+ new HitCircle { Position = new Vector2(500, 500) },
+ });
+
+ private void addObjectsStep(Func ctorFunc)
+ {
+ AddStep("add hitobjects", () =>
+ {
+ var objects = ctorFunc();
+
+ for (int i = 0; i < objects.Length; i++)
+ {
+ objects[i].StartTime = Time.Current + 1000 + 500 * (i + 1);
+ objects[i].ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
+
+ DrawableOsuHitObject drawableObject = null;
+
+ switch (objects[i])
+ {
+ case HitCircle circle:
+ drawableObject = new DrawableHitCircle(circle);
+ break;
+
+ case Slider slider:
+ drawableObject = new DrawableSlider(slider);
+ break;
+
+ case Spinner spinner:
+ drawableObject = new DrawableSpinner(spinner);
+ break;
+ }
+
+ hitObjectContainer.Add(drawableObject);
+ followPointRenderer.AddFollowPoints(drawableObject);
+ }
+ });
+ }
+
+ private void removeObjectStep(Func getFunc)
+ {
+ AddStep("remove hitobject", () =>
+ {
+ var drawableObject = getFunc?.Invoke();
+
+ hitObjectContainer.Remove(drawableObject);
+ followPointRenderer.RemoveFollowPoints(drawableObject);
+ });
+ }
+
+ private void reorderObjectStep(int startIndex, int endIndex)
+ {
+ AddStep($"move object {startIndex} to {endIndex}", () =>
+ {
+ DrawableOsuHitObject toReorder = getObject(startIndex);
+
+ double targetTime;
+ if (endIndex < hitObjectContainer.Count)
+ targetTime = getObject(endIndex).HitObject.StartTime - 1;
+ else
+ targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1;
+
+ hitObjectContainer.Remove(toReorder);
+ toReorder.HitObject.StartTime = targetTime;
+ hitObjectContainer.Add(toReorder);
+ });
+ }
+
+ private void assertGroups()
+ {
+ AddAssert("has correct group count", () => followPointRenderer.Connections.Count == hitObjectContainer.Count);
+ AddAssert("group endpoints are correct", () =>
+ {
+ for (int i = 0; i < hitObjectContainer.Count; i++)
+ {
+ DrawableOsuHitObject expectedStart = getObject(i);
+ DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null;
+
+ if (getGroup(i).Start != expectedStart)
+ throw new AssertionException($"Object {i} expected to be the start of group {i}.");
+
+ if (getGroup(i).End != expectedEnd)
+ throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}.");
+ }
+
+ return true;
+ });
+ }
+
+ private DrawableOsuHitObject getObject(int index) => hitObjectContainer[index];
+
+ private FollowPointConnection getGroup(int index) => followPointRenderer.Connections[index];
+
+ private class TestHitObjectContainer : Container
+ {
+ protected override int Compare(Drawable x, Drawable y)
+ {
+ var osuX = (DrawableOsuHitObject)x;
+ var osuY = (DrawableOsuHitObject)y;
+
+ int compare = osuX.HitObject.StartTime.CompareTo(osuY.HitObject.StartTime);
+
+ if (compare == 0)
+ return base.Compare(x, y);
+
+ return compare;
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs
index 84a7bfc53e..64f353c4d9 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs
@@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private Drawable testSingle(float circleSize, bool auto = false, double timeOffset = 0, Vector2? positionOffset = null)
{
- positionOffset = positionOffset ?? Vector2.Zero;
+ positionOffset ??= Vector2.Zero;
var circle = new HitCircle
{
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
index 95c2810e94..b99cd523ff 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs
@@ -29,8 +29,10 @@ namespace osu.Game.Rulesets.Osu.Tests
};
for (int i = 0; i < 512; i++)
+ {
if (i % 32 < 20)
beatmap.HitObjects.Add(new HitCircle { Position = new Vector2(256, 192), StartTime = i * 100 });
+ }
return beatmap;
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs
index d4cdabdb07..0ecce42e88 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs
@@ -52,12 +52,19 @@ namespace osu.Game.Rulesets.Osu.Tests
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
}
+ [Test]
+ public void TestStackedHitObject()
+ {
+ AddStep("set stacking", () => hitCircle.StackHeight = 5);
+ AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.StackedPosition);
+ }
+
private class TestBlueprint : HitCircleSelectionBlueprint
{
public new HitCirclePiece CirclePiece => base.CirclePiece;
- public TestBlueprint(DrawableHitCircle hitCircle)
- : base(hitCircle)
+ public TestBlueprint(DrawableHitCircle drawableCircle)
+ : base(drawableCircle)
{
}
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs
new file mode 100644
index 0000000000..eff4d919b0
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs
@@ -0,0 +1,197 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Events;
+using osu.Framework.MathUtils;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Edit;
+using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Osu.Edit;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osu.Game.Screens.Edit.Compose.Components;
+using osu.Game.Tests.Visual;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneOsuDistanceSnapGrid : ManualInputManagerTestScene
+ {
+ private const double beat_length = 100;
+ private static readonly Vector2 grid_position = new Vector2(512, 384);
+
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(CircularDistanceSnapGrid)
+ };
+
+ [Cached(typeof(IEditorBeatmap))]
+ private readonly EditorBeatmap editorBeatmap;
+
+ [Cached]
+ private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
+
+ [Cached(typeof(IDistanceSnapProvider))]
+ private readonly SnapProvider snapProvider = new SnapProvider();
+
+ private TestOsuDistanceSnapGrid grid;
+
+ public TestSceneOsuDistanceSnapGrid()
+ {
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ }
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
+ editorBeatmap.ControlPointInfo.Clear();
+ editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
+
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.SlateGray
+ },
+ grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
+ new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnappedPosition(grid.ToLocalSpace(v)).position }
+ };
+ });
+
+ [TestCase(1)]
+ [TestCase(2)]
+ [TestCase(3)]
+ [TestCase(4)]
+ [TestCase(6)]
+ [TestCase(8)]
+ [TestCase(12)]
+ [TestCase(16)]
+ public void TestBeatDivisor(int divisor)
+ {
+ AddStep($"set beat divisor = {divisor}", () => beatDivisor.Value = divisor);
+ }
+
+ [Test]
+ public void TestCursorInCentre()
+ {
+ AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position)));
+ assertSnappedDistance((float)beat_length);
+ }
+
+ [Test]
+ public void TestCursorBeforeMovementPoint()
+ {
+ AddStep("move mouse to just before movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.49f)));
+ assertSnappedDistance((float)beat_length);
+ }
+
+ [Test]
+ public void TestCursorAfterMovementPoint()
+ {
+ AddStep("move mouse to just after movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.51f)));
+ assertSnappedDistance((float)beat_length * 2);
+ }
+
+ [Test]
+ public void TestLimitedDistance()
+ {
+ AddStep("create limited grid", () =>
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.SlateGray
+ },
+ grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }, new HitCircle { StartTime = 200 }),
+ new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnappedPosition(grid.ToLocalSpace(v)).position }
+ };
+ });
+
+ AddStep("move mouse outside grid", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 3f)));
+ assertSnappedDistance((float)beat_length * 2);
+ }
+
+ private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
+ {
+ Vector2 snappedPosition = grid.GetSnappedPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position)).position;
+
+ return Precision.AlmostEquals(expectedDistance, Vector2.Distance(snappedPosition, grid_position));
+ });
+
+ private class SnappingCursorContainer : CompositeDrawable
+ {
+ public Func GetSnapPosition;
+
+ private readonly Drawable cursor;
+
+ public SnappingCursorContainer()
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChild = cursor = new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(50),
+ Colour = Color4.Red
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ updatePosition(GetContainingInputManager().CurrentState.Mouse.Position);
+ }
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ base.OnMouseMove(e);
+
+ updatePosition(e.ScreenSpaceMousePosition);
+ return true;
+ }
+
+ private void updatePosition(Vector2 screenSpacePosition)
+ {
+ cursor.Position = GetSnapPosition.Invoke(screenSpacePosition);
+ }
+ }
+
+ private class TestOsuDistanceSnapGrid : OsuDistanceSnapGrid
+ {
+ public new float DistanceSpacing => base.DistanceSpacing;
+
+ public TestOsuDistanceSnapGrid(OsuHitObject hitObject, OsuHitObject nextHitObject = null)
+ : base(hitObject, nextHitObject)
+ {
+ }
+ }
+
+ private class SnapProvider : IDistanceSnapProvider
+ {
+ public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => (position, time);
+
+ public float GetBeatSnapDistanceAt(double referenceTime) => (float)beat_length;
+
+ public float DurationToDistance(double referenceTime, double duration) => (float)duration;
+
+ public double DistanceToDuration(double referenceTime, float distance) => distance;
+
+ public double GetSnappedDurationFromDistance(double referenceTime, float distance) => 0;
+
+ public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => 0;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
index 02c65db6ad..4da1b1dae0 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
@@ -16,9 +16,11 @@ using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
+using osu.Game.Storyboards;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
@@ -75,14 +77,14 @@ namespace osu.Game.Rulesets.Osu.Tests
protected override Player CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(testUserSkin);
- protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => new CustomSkinWorkingBeatmap(beatmap, Clock, audio, testBeatmapSkin);
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, audio, testBeatmapSkin);
public class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
{
private readonly ISkinSource skin;
- public CustomSkinWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin)
- : base(beatmap, frameBasedClock, audio)
+ public CustomSkinWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin)
+ : base(beatmap, storyboard, frameBasedClock, audio)
{
this.skin = skin;
}
@@ -124,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
if (!enabled) return null;
- return new SpriteText
+ return new OsuSpriteText
{
Text = identifier,
Font = OsuFont.Default.With(size: 30),
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs
index 6a4201f84d..a9d5c03517 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs
@@ -111,6 +111,83 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("Distance Overflow 1 Repeat", () => SetContents(() => testDistanceOverflow(1)));
}
+ [Test]
+ public void TestChangeStackHeight()
+ {
+ DrawableSlider slider = null;
+
+ AddStep("create slider", () =>
+ {
+ slider = (DrawableSlider)createSlider(repeats: 1);
+ Add(slider);
+ });
+
+ AddStep("change stack height", () => slider.HitObject.StackHeight = 10);
+ AddAssert("body positioned correctly", () => slider.Position == slider.HitObject.StackedPosition);
+ }
+
+ [Test]
+ public void TestChangeSamplesWithNoNodeSamples()
+ {
+ DrawableSlider slider = null;
+
+ AddStep("create slider", () =>
+ {
+ slider = (DrawableSlider)createSlider(repeats: 1);
+ Add(slider);
+ });
+
+ AddStep("change samples", () => slider.HitObject.Samples = new[]
+ {
+ new HitSampleInfo { Name = HitSampleInfo.HIT_CLAP },
+ new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE },
+ });
+
+ AddAssert("head samples updated", () => assertSamples(((Slider)slider.HitObject).HeadCircle));
+ AddAssert("tick samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType().All(assertTickSamples));
+ AddAssert("repeat samples updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType().All(assertSamples));
+ AddAssert("tail has no samples", () => ((Slider)slider.HitObject).TailCircle.Samples.Count == 0);
+
+ static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick";
+
+ static bool assertSamples(HitObject hitObject)
+ {
+ return hitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)
+ && hitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE);
+ }
+ }
+
+ [Test]
+ public void TestChangeSamplesWithNodeSamples()
+ {
+ DrawableSlider slider = null;
+
+ AddStep("create slider", () =>
+ {
+ slider = (DrawableSlider)createSlider(repeats: 1);
+
+ for (int i = 0; i < 2; i++)
+ ((Slider)slider.HitObject).NodeSamples.Add(new List { new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH } });
+
+ Add(slider);
+ });
+
+ AddStep("change samples", () => slider.HitObject.Samples = new[]
+ {
+ new HitSampleInfo { Name = HitSampleInfo.HIT_CLAP },
+ new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE },
+ });
+
+ AddAssert("head samples not updated", () => assertSamples(((Slider)slider.HitObject).HeadCircle));
+ AddAssert("tick samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType().All(assertTickSamples));
+ AddAssert("repeat samples not updated", () => ((Slider)slider.HitObject).NestedHitObjects.OfType().All(assertSamples));
+ AddAssert("tail has no samples", () => ((Slider)slider.HitObject).TailCircle.Samples.Count == 0);
+
+ static bool assertTickSamples(SliderTick tick) => tick.Samples.Single().Name == "slidertick";
+
+ static bool assertSamples(HitObject hitObject) => hitObject.Samples.All(s => s.Name != HitSampleInfo.HIT_CLAP && s.Name != HitSampleInfo.HIT_WHISTLE);
+ }
+
private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats);
private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10);
@@ -128,7 +205,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(52, -34)
}, 700),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats),
StackHeight = 10
};
@@ -159,7 +235,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(distance, 0),
}, distance),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats),
StackHeight = stackHeight
};
@@ -179,7 +254,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(400, 0)
}, 600),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats)
};
return createDrawable(slider, 2, 3);
@@ -203,7 +277,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(430, 0)
}),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats)
};
return createDrawable(slider, 2, 3);
@@ -226,7 +299,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(430, 0)
}),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats)
};
return createDrawable(slider, 2, 3);
@@ -250,7 +322,6 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(0, -200)
}),
RepeatCount = repeats,
- NodeSamples = createEmptySamples(repeats)
};
return createDrawable(slider, 2, 3);
@@ -260,7 +331,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private Drawable createCatmull(int repeats = 0)
{
- var repeatSamples = new List>();
+ var repeatSamples = new List>();
for (int i = 0; i < repeats; i++)
repeatSamples.Add(new List());
@@ -282,18 +353,10 @@ namespace osu.Game.Rulesets.Osu.Tests
return createDrawable(slider, 3, 1);
}
- private List> createEmptySamples(int repeats)
- {
- var repeatSamples = new List>();
- for (int i = 0; i < repeats; i++)
- repeatSamples.Add(new List());
- return repeatSamples;
- }
-
private Drawable createDrawable(Slider slider, float circleSize, double speedMultiplier)
{
var cpi = new ControlPointInfo();
- cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
+ cpi.Add(0, new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize, SliderTickRate = 3 });
@@ -317,8 +380,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{
- var osuObject = judgedObject as DrawableOsuHitObject;
- if (osuObject == null)
+ if (!(judgedObject is DrawableOsuHitObject osuObject))
return;
OsuSpriteText text;
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
index 2eb783233a..5f75cbabec 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
@@ -313,10 +313,6 @@ namespace osu.Game.Rulesets.Osu.Tests
}, 25),
}
},
- ControlPointInfo =
- {
- DifficultyPoints = { new DifficultyControlPoint { SpeedMultiplier = 0.1f } }
- },
BeatmapInfo =
{
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
@@ -324,6 +320,8 @@ namespace osu.Game.Rulesets.Osu.Tests
},
});
+ Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
+
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
p.OnLoadComplete += _ =>
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSelectionBlueprint.cs
index ec23ec31b2..013920684c 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSelectionBlueprint.cs
@@ -16,6 +16,7 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using osuTK;
+using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Tests
{
@@ -78,6 +79,100 @@ namespace osu.Game.Rulesets.Osu.Tests
checkPositions();
}
+ [Test]
+ public void TestStackedHitObject()
+ {
+ AddStep("set stacking", () => slider.StackHeight = 5);
+ checkPositions();
+ }
+
+ [Test]
+ public void TestSingleControlPointSelection()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkControlPointSelected(0, true);
+ checkControlPointSelected(1, false);
+ }
+
+ [Test]
+ public void TestSingleControlPointDeselectionViaOtherControlPoint()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+
+ moveMouseToControlPoint(1);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkControlPointSelected(0, false);
+ checkControlPointSelected(1, true);
+ }
+
+ [Test]
+ public void TestSingleControlPointDeselectionViaClickOutside()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+
+ AddStep("move mouse outside control point", () => InputManager.MoveMouseTo(drawableObject));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkControlPointSelected(0, false);
+ checkControlPointSelected(1, false);
+ }
+
+ [Test]
+ public void TestMultipleControlPointSelection()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ moveMouseToControlPoint(1);
+ AddStep("ctrl + click", () =>
+ {
+ InputManager.PressKey(Key.ControlLeft);
+ InputManager.Click(MouseButton.Left);
+ InputManager.ReleaseKey(Key.ControlLeft);
+ });
+ checkControlPointSelected(0, true);
+ checkControlPointSelected(1, true);
+ }
+
+ [Test]
+ public void TestMultipleControlPointDeselectionViaOtherControlPoint()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ moveMouseToControlPoint(1);
+ AddStep("ctrl + click", () =>
+ {
+ InputManager.PressKey(Key.ControlLeft);
+ InputManager.Click(MouseButton.Left);
+ InputManager.ReleaseKey(Key.ControlLeft);
+ });
+
+ moveMouseToControlPoint(2);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkControlPointSelected(0, false);
+ checkControlPointSelected(1, false);
+ }
+
+ [Test]
+ public void TestMultipleControlPointDeselectionViaClickOutside()
+ {
+ moveMouseToControlPoint(0);
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ moveMouseToControlPoint(1);
+ AddStep("ctrl + click", () =>
+ {
+ InputManager.PressKey(Key.ControlLeft);
+ InputManager.Click(MouseButton.Left);
+ InputManager.ReleaseKey(Key.ControlLeft);
+ });
+
+ AddStep("move mouse outside control point", () => InputManager.MoveMouseTo(drawableObject));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkControlPointSelected(0, false);
+ checkControlPointSelected(1, false);
+ }
+
private void moveHitObject()
{
AddStep("move hitobject", () =>
@@ -88,7 +183,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private void checkPositions()
{
- AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.Position);
+ AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.StackedPosition);
AddAssert("head positioned correctly",
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
@@ -97,11 +192,24 @@ namespace osu.Game.Rulesets.Osu.Tests
() => Precision.AlmostEquals(blueprint.TailBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.TailCircle.ScreenSpaceDrawQuad.Centre));
}
+ private void moveMouseToControlPoint(int index)
+ {
+ AddStep($"move mouse to control point {index}", () =>
+ {
+ Vector2 position = slider.Position + slider.Path.ControlPoints[index].Position.Value;
+ InputManager.MoveMouseTo(drawableObject.Parent.ToScreenSpace(position));
+ });
+ }
+
+ private void checkControlPointSelected(int index, bool selected)
+ => AddAssert($"control point {index} {(selected ? "selected" : "not selected")}", () => blueprint.ControlPointVisualiser.Pieces[index].IsSelected.Value == selected);
+
private class TestSliderBlueprint : SliderSelectionBlueprint
{
public new SliderBodyPiece BodyPiece => base.BodyPiece;
public new TestSliderCircleBlueprint HeadBlueprint => (TestSliderCircleBlueprint)base.HeadBlueprint;
public new TestSliderCircleBlueprint TailBlueprint => (TestSliderCircleBlueprint)base.TailBlueprint;
+ public new PathControlPointVisualiser ControlPointVisualiser => base.ControlPointVisualiser;
public TestSliderBlueprint(DrawableSlider slider)
: base(slider)
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs
index b03788a7d6..8608a4a045 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs
@@ -17,6 +17,7 @@ using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
+using osu.Game.Storyboards;
using static osu.Game.Tests.Visual.OsuTestScene.ClockBackedTestWorkingBeatmap;
namespace osu.Game.Rulesets.Osu.Tests
@@ -32,9 +33,9 @@ namespace osu.Game.Rulesets.Osu.Tests
protected override Player CreatePlayer(Ruleset ruleset) => new ScoreExposedPlayer();
- protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
{
- var working = new ClockBackedTestWorkingBeatmap(beatmap, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
+ var working = new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
track = (TrackVirtualManual)working.Track;
return working;
}
diff --git a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
index 3aea9e0387..fddf176fd0 100644
--- a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
+++ b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs
index 6a41e93c35..2296030f81 100644
--- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs
@@ -9,6 +9,7 @@ using System.Collections.Generic;
using osu.Game.Rulesets.Objects.Types;
using System;
using osu.Game.Rulesets.Osu.UI;
+using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Osu.Beatmaps
{
@@ -23,52 +24,48 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
protected override IEnumerable ConvertHitObject(HitObject original, IBeatmap beatmap)
{
- var curveData = original as IHasCurve;
- var endTimeData = original as IHasEndTime;
var positionData = original as IHasPosition;
var comboData = original as IHasCombo;
- var legacyOffset = original as IHasLegacyLastTickOffset;
- if (curveData != null)
+ switch (original)
{
- yield return new Slider
- {
- StartTime = original.StartTime,
- Samples = original.Samples,
- Path = curveData.Path,
- NodeSamples = curveData.NodeSamples,
- RepeatCount = curveData.RepeatCount,
- Position = positionData?.Position ?? Vector2.Zero,
- NewCombo = comboData?.NewCombo ?? false,
- ComboOffset = comboData?.ComboOffset ?? 0,
- LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset,
- // prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance.
- // this results in more (or less) ticks being generated in stackThreshold)
@@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
OsuHitObject objectN = beatmap.HitObjects[n];
if (objectN is Spinner) continue;
- double endTime = (objectN as IHasEndTime)?.EndTime ?? objectN.StartTime;
+ double endTime = objectN.GetEndTime();
if (objectI.StartTime - endTime > stackThreshold)
//We are no longer within stacking range of the previous object.
@@ -199,7 +199,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
if (currHitObject.StackHeight != 0 && !(currHitObject is Slider))
continue;
- double startTime = (currHitObject as IHasEndTime)?.EndTime ?? currHitObject.StartTime;
+ double startTime = currHitObject.GetEndTime();
int sliderStack = 0;
for (int j = i + 1; j < beatmap.HitObjects.Count; j++)
@@ -217,14 +217,14 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
if (Vector2Extensions.Distance(beatmap.HitObjects[j].Position, currHitObject.Position) < stack_distance)
{
currHitObject.StackHeight++;
- startTime = (beatmap.HitObjects[j] as IHasEndTime)?.EndTime ?? beatmap.HitObjects[j].StartTime;
+ startTime = beatmap.HitObjects[j].GetEndTime();
}
else if (Vector2Extensions.Distance(beatmap.HitObjects[j].Position, position2) < stack_distance)
{
//Case for sliders - bump notes down and right, rather than up and left.
sliderStack++;
beatmap.HitObjects[j].StackHeight -= sliderStack;
- startTime = (beatmap.HitObjects[j] as IHasEndTime)?.EndTime ?? beatmap.HitObjects[j].StartTime;
+ startTime = beatmap.HitObjects[j].GetEndTime();
}
}
}
diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
index 093081b6a1..ce8ecf02ac 100644
--- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
+++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
@@ -45,32 +45,32 @@ namespace osu.Game.Rulesets.Osu.Difficulty
mods = Score.Mods;
accuracy = Score.Accuracy;
scoreMaxCombo = Score.MaxCombo;
- countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
- countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
- countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
- countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
+ countGreat = Score.Statistics[HitResult.Great];
+ countGood = Score.Statistics[HitResult.Good];
+ countMeh = Score.Statistics[HitResult.Meh];
+ countMiss = Score.Statistics[HitResult.Miss];
// Don't count scores made with supposedly unranked mods
if (mods.Any(m => !m.Ranked))
return 0;
// Custom multipliers for NoFail and SpunOut.
- double multiplier = 1.12f; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
+ double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
if (mods.Any(m => m is OsuModNoFail))
- multiplier *= 0.90f;
+ multiplier *= 0.90;
if (mods.Any(m => m is OsuModSpunOut))
- multiplier *= 0.95f;
+ multiplier *= 0.95;
double aimValue = computeAimValue();
double speedValue = computeSpeedValue();
double accuracyValue = computeAccuracyValue();
double totalValue =
Math.Pow(
- Math.Pow(aimValue, 1.1f) +
- Math.Pow(speedValue, 1.1f) +
- Math.Pow(accuracyValue, 1.1f), 1.0f / 1.1f
+ Math.Pow(aimValue, 1.1) +
+ Math.Pow(speedValue, 1.1) +
+ Math.Pow(accuracyValue, 1.1), 1.0 / 1.1
) * multiplier;
if (categoryRatings != null)
@@ -93,82 +93,82 @@ namespace osu.Game.Rulesets.Osu.Difficulty
if (mods.Any(m => m is OsuModTouchDevice))
rawAim = Math.Pow(rawAim, 0.8);
- double aimValue = Math.Pow(5.0f * Math.Max(1.0f, rawAim / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
+ double aimValue = Math.Pow(5.0 * Math.Max(1.0, rawAim / 0.0675) - 4.0, 3.0) / 100000.0;
// Longer maps are worth more
- double lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +
- (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f);
+ double lengthBonus = 0.95 + 0.4 * Math.Min(1.0, totalHits / 2000.0) +
+ (totalHits > 2000 ? Math.Log10(totalHits / 2000.0) * 0.5 : 0.0);
aimValue *= lengthBonus;
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
- aimValue *= Math.Pow(0.97f, countMiss);
+ aimValue *= Math.Pow(0.97, countMiss);
// Combo scaling
if (beatmapMaxCombo > 0)
- aimValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);
+ aimValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(beatmapMaxCombo, 0.8), 1.0);
- double approachRateFactor = 1.0f;
+ double approachRateFactor = 1.0;
- if (Attributes.ApproachRate > 10.33f)
- approachRateFactor += 0.3f * (Attributes.ApproachRate - 10.33f);
- else if (Attributes.ApproachRate < 8.0f)
+ if (Attributes.ApproachRate > 10.33)
+ approachRateFactor += 0.3 * (Attributes.ApproachRate - 10.33);
+ else if (Attributes.ApproachRate < 8.0)
{
- approachRateFactor += 0.01f * (8.0f - Attributes.ApproachRate);
+ approachRateFactor += 0.01 * (8.0 - Attributes.ApproachRate);
}
aimValue *= approachRateFactor;
// We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
if (mods.Any(h => h is OsuModHidden))
- aimValue *= 1.0f + 0.04f * (12.0f - Attributes.ApproachRate);
+ aimValue *= 1.0 + 0.04 * (12.0 - Attributes.ApproachRate);
if (mods.Any(h => h is OsuModFlashlight))
{
// Apply object-based bonus for flashlight.
- aimValue *= 1.0f + 0.35f * Math.Min(1.0f, totalHits / 200.0f) +
+ aimValue *= 1.0 + 0.35 * Math.Min(1.0, totalHits / 200.0) +
(totalHits > 200
- ? 0.3f * Math.Min(1.0f, (totalHits - 200) / 300.0f) +
- (totalHits > 500 ? (totalHits - 500) / 1200.0f : 0.0f)
- : 0.0f);
+ ? 0.3 * Math.Min(1.0, (totalHits - 200) / 300.0) +
+ (totalHits > 500 ? (totalHits - 500) / 1200.0 : 0.0)
+ : 0.0);
}
// Scale the aim value with accuracy _slightly_
- aimValue *= 0.5f + accuracy / 2.0f;
+ aimValue *= 0.5 + accuracy / 2.0;
// It is important to also consider accuracy difficulty when doing that
- aimValue *= 0.98f + Math.Pow(Attributes.OverallDifficulty, 2) / 2500;
+ aimValue *= 0.98 + Math.Pow(Attributes.OverallDifficulty, 2) / 2500;
return aimValue;
}
private double computeSpeedValue()
{
- double speedValue = Math.Pow(5.0f * Math.Max(1.0f, Attributes.SpeedStrain / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
+ double speedValue = Math.Pow(5.0 * Math.Max(1.0, Attributes.SpeedStrain / 0.0675) - 4.0, 3.0) / 100000.0;
// Longer maps are worth more
- speedValue *= 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +
- (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f);
+ speedValue *= 0.95 + 0.4 * Math.Min(1.0, totalHits / 2000.0) +
+ (totalHits > 2000 ? Math.Log10(totalHits / 2000.0) * 0.5 : 0.0);
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
- speedValue *= Math.Pow(0.97f, countMiss);
+ speedValue *= Math.Pow(0.97, countMiss);
// Combo scaling
if (beatmapMaxCombo > 0)
- speedValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);
+ speedValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(beatmapMaxCombo, 0.8), 1.0);
- double approachRateFactor = 1.0f;
- if (Attributes.ApproachRate > 10.33f)
- approachRateFactor += 0.3f * (Attributes.ApproachRate - 10.33f);
+ double approachRateFactor = 1.0;
+ if (Attributes.ApproachRate > 10.33)
+ approachRateFactor += 0.3 * (Attributes.ApproachRate - 10.33);
speedValue *= approachRateFactor;
if (mods.Any(m => m is OsuModHidden))
- speedValue *= 1.0f + 0.04f * (12.0f - Attributes.ApproachRate);
+ speedValue *= 1.0 + 0.04 * (12.0 - Attributes.ApproachRate);
// Scale the speed value with accuracy _slightly_
- speedValue *= 0.02f + accuracy;
+ speedValue *= 0.02 + accuracy;
// It is important to also consider accuracy difficulty when doing that
- speedValue *= 0.96f + Math.Pow(Attributes.OverallDifficulty, 2) / 1600;
+ speedValue *= 0.96 + Math.Pow(Attributes.OverallDifficulty, 2) / 1600;
return speedValue;
}
@@ -190,15 +190,15 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Lots of arbitrary values from testing.
// Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
- double accuracyValue = Math.Pow(1.52163f, Attributes.OverallDifficulty) * Math.Pow(betterAccuracyPercentage, 24) * 2.83f;
+ double accuracyValue = Math.Pow(1.52163, Attributes.OverallDifficulty) * Math.Pow(betterAccuracyPercentage, 24) * 2.83;
// Bonus for many hitcircles - it's harder to keep good accuracy up for longer
- accuracyValue *= Math.Min(1.15f, Math.Pow(amountHitObjectsWithAccuracy / 1000.0f, 0.3f));
+ accuracyValue *= Math.Min(1.15, Math.Pow(amountHitObjectsWithAccuracy / 1000.0, 0.3));
if (mods.Any(m => m is OsuModHidden))
- accuracyValue *= 1.08f;
+ accuracyValue *= 1.08;
if (mods.Any(m => m is OsuModFlashlight))
- accuracyValue *= 1.02f;
+ accuracyValue *= 1.02;
return accuracyValue;
}
diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs
index eacac7ae6a..fa6c5c4d9c 100644
--- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs
+++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs
@@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
if (progress % 2 >= 1)
progress = 1 - progress % 1;
else
- progress = progress % 1;
+ progress %= 1;
// ReSharper disable once PossibleInvalidOperationException (bugged in current r# version)
var diff = slider.StackedPosition + slider.Path.PositionAt(progress) - slider.LazyEndPosition.Value;
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs
index 95e926fdfa..b9c77d3f56 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
/// The to reference properties from.
public virtual void UpdateFrom(T hitObject)
{
- Position = hitObject.Position;
+ Position = hitObject.StackedPosition;
}
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs
index 2b6b93a590..2868ddeaa4 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs
@@ -17,7 +17,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
+
CornerRadius = Size.X / 2;
+ CornerExponent = 2;
InternalChild = new RingPiece();
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
index 6c08990ad6..bb47c7e464 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
@@ -30,7 +30,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
protected override bool OnClick(ClickEvent e)
{
- HitObject.StartTime = EditorClock.CurrentTime;
EndPlacement();
return true;
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs
index a191dba8ff..093bae854e 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs
@@ -1,18 +1,22 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osuTK;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
{
public class HitCircleSelectionBlueprint : OsuSelectionBlueprint
{
+ protected new DrawableHitCircle DrawableObject => (DrawableHitCircle)base.DrawableObject;
+
protected readonly HitCirclePiece CirclePiece;
- public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
- : base(hitCircle)
+ public HitCircleSelectionBlueprint(DrawableHitCircle drawableCircle)
+ : base(drawableCircle)
{
InternalChild = CirclePiece = new HitCirclePiece();
}
@@ -23,5 +27,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
CirclePiece.UpdateFrom(HitObject);
}
+
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.HitArea.ReceivePositionalInputAt(screenSpacePos);
+
+ public override Quad SelectionQuad => DrawableObject.HitArea.ScreenSpaceDrawQuad;
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs
index 2e4b990db8..a864257274 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs
@@ -10,10 +10,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
public abstract class OsuSelectionBlueprint : SelectionBlueprint
where T : OsuHitObject
{
- protected new T HitObject => (T)base.HitObject.HitObject;
+ protected T HitObject => (T)DrawableObject.HitObject;
- protected OsuSelectionBlueprint(DrawableHitObject hitObject)
- : base(hitObject)
+ protected OsuSelectionBlueprint(DrawableHitObject drawableObject)
+ : base(drawableObject)
{
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
index 3aec7c2872..c2aefac587 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
@@ -1,34 +1,51 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
+using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;
+using osuTK.Graphics;
+using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
public class PathControlPointPiece : BlueprintPiece
{
- private readonly Slider slider;
- private readonly int index;
+ public Action RequestSelection;
+ public readonly BindableBool IsSelected = new BindableBool();
+
+ public readonly PathControlPoint ControlPoint;
+
+ private readonly Slider slider;
private readonly Path path;
- private readonly CircularContainer marker;
+ private readonly Container marker;
+ private readonly Drawable markerRing;
+
+ [Resolved(CanBeNull = true)]
+ private IDistanceSnapProvider snapProvider { get; set; }
[Resolved]
private OsuColour colours { get; set; }
- public PathControlPointPiece(Slider slider, int index)
+ private IBindable sliderPosition;
+ private IBindable pathVersion;
+
+ public PathControlPointPiece(Slider slider, PathControlPoint controlPoint)
{
this.slider = slider;
- this.index = index;
+
+ ControlPoint = controlPoint;
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
@@ -40,73 +57,158 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
Anchor = Anchor.Centre,
PathRadius = 1
},
- marker = new CircularContainer
+ marker = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- Size = new Vector2(10),
- Masking = true,
- Child = new Box { RelativeSizeAxes = Axes.Both }
+ AutoSizeAxes = Axes.Both,
+ Children = new[]
+ {
+ new Circle
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(10),
+ },
+ markerRing = new CircularContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(14),
+ Masking = true,
+ BorderThickness = 2,
+ BorderColour = Color4.White,
+ Alpha = 0,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Alpha = 0,
+ AlwaysPresent = true
+ }
+ }
+ }
}
};
}
- protected override void Update()
+ protected override void LoadComplete()
{
- base.Update();
+ base.LoadComplete();
- Position = slider.StackedPosition + slider.Path.ControlPoints[index];
+ sliderPosition = slider.PositionBindable.GetBoundCopy();
+ sliderPosition.BindValueChanged(_ => updateDisplay());
- marker.Colour = isSegmentSeparator ? colours.Red : colours.Yellow;
+ pathVersion = slider.Path.Version.GetBoundCopy();
+ pathVersion.BindValueChanged(_ => updateDisplay());
- path.ClearVertices();
+ IsSelected.BindValueChanged(_ => updateMarkerDisplay());
- if (index != slider.Path.ControlPoints.Length - 1)
- {
- path.AddVertex(Vector2.Zero);
- path.AddVertex(slider.Path.ControlPoints[index + 1] - slider.Path.ControlPoints[index]);
- }
-
- path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
+ updateDisplay();
}
+ private void updateDisplay()
+ {
+ updateMarkerDisplay();
+ updateConnectingPath();
+ }
+
+ // The connecting path is excluded from positional input
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
- protected override bool OnDragStart(DragStartEvent e) => true;
+ protected override bool OnHover(HoverEvent e)
+ {
+ updateMarkerDisplay();
+ return false;
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ updateMarkerDisplay();
+ }
+
+ protected override bool OnMouseDown(MouseDownEvent e)
+ {
+ if (RequestSelection == null)
+ return false;
+
+ switch (e.Button)
+ {
+ case MouseButton.Left:
+ RequestSelection.Invoke(this, e);
+ return true;
+
+ case MouseButton.Right:
+ if (!IsSelected.Value)
+ RequestSelection.Invoke(this, e);
+ return false; // Allow context menu to show
+ }
+
+ return false;
+ }
+
+ protected override bool OnMouseUp(MouseUpEvent e) => RequestSelection != null;
+
+ protected override bool OnClick(ClickEvent e) => RequestSelection != null;
+
+ protected override bool OnDragStart(DragStartEvent e) => e.Button == MouseButton.Left;
protected override bool OnDrag(DragEvent e)
{
- var newControlPoints = slider.Path.ControlPoints.ToArray();
-
- if (index == 0)
+ if (ControlPoint == slider.Path.ControlPoints[0])
{
- // Special handling for the head - only the position of the slider changes
- slider.Position += e.Delta;
+ // Special handling for the head control point - the position of the slider changes which means the snapped position and time have to be taken into account
+ (Vector2 snappedPosition, double snappedTime) = snapProvider?.GetSnappedPosition(e.MousePosition, slider.StartTime) ?? (e.MousePosition, slider.StartTime);
+ Vector2 movementDelta = snappedPosition - slider.Position;
+
+ slider.Position += movementDelta;
+ slider.StartTime = snappedTime;
// Since control points are relative to the position of the slider, they all need to be offset backwards by the delta
- for (int i = 1; i < newControlPoints.Length; i++)
- newControlPoints[i] -= e.Delta;
+ for (int i = 1; i < slider.Path.ControlPoints.Count; i++)
+ slider.Path.ControlPoints[i].Position.Value -= movementDelta;
}
else
- newControlPoints[index] += e.Delta;
-
- if (isSegmentSeparatorWithNext)
- newControlPoints[index + 1] = newControlPoints[index];
-
- if (isSegmentSeparatorWithPrevious)
- newControlPoints[index - 1] = newControlPoints[index];
-
- slider.Path = new SliderPath(slider.Path.Type, newControlPoints);
+ ControlPoint.Position.Value += e.Delta;
return true;
}
protected override bool OnDragEnd(DragEndEvent e) => true;
- private bool isSegmentSeparator => isSegmentSeparatorWithNext || isSegmentSeparatorWithPrevious;
+ ///
+ /// Updates the state of the circular control point marker.
+ ///
+ private void updateMarkerDisplay()
+ {
+ Position = slider.StackedPosition + ControlPoint.Position.Value;
- private bool isSegmentSeparatorWithNext => index < slider.Path.ControlPoints.Length - 1 && slider.Path.ControlPoints[index + 1] == slider.Path.ControlPoints[index];
+ markerRing.Alpha = IsSelected.Value ? 1 : 0;
- private bool isSegmentSeparatorWithPrevious => index > 0 && slider.Path.ControlPoints[index - 1] == slider.Path.ControlPoints[index];
+ Color4 colour = ControlPoint.Type.Value != null ? colours.Red : colours.Yellow;
+ if (IsHovered || IsSelected.Value)
+ colour = Color4.White;
+ marker.Colour = colour;
+ }
+
+ ///
+ /// Updates the path connecting this control point to the previous one.
+ ///
+ private void updateConnectingPath()
+ {
+ path.ClearVertices();
+
+ int index = slider.Path.ControlPoints.IndexOf(ControlPoint);
+
+ if (index == -1)
+ return;
+
+ if (++index != slider.Path.ControlPoints.Count)
+ {
+ path.AddVertex(Vector2.Zero);
+ path.AddVertex(slider.Path.ControlPoints[index].Position.Value - ControlPoint.Position.Value);
+ }
+
+ path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
+ }
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
index 24fcc460d1..cd19653a2e 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
@@ -1,33 +1,197 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Humanizer;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Cursor;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Input;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
+using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
- public class PathControlPointVisualiser : CompositeDrawable
+ public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler, IHasContextMenu
{
+ internal readonly Container Pieces;
+
private readonly Slider slider;
- private readonly Container pieces;
+ private readonly bool allowSelection;
- public PathControlPointVisualiser(Slider slider)
+ private InputManager inputManager;
+
+ private IBindableList controlPoints;
+
+ public Action> RemoveControlPointsRequested;
+
+ public PathControlPointVisualiser(Slider slider, bool allowSelection)
{
this.slider = slider;
+ this.allowSelection = allowSelection;
- InternalChild = pieces = new Container { RelativeSizeAxes = Axes.Both };
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChild = Pieces = new Container { RelativeSizeAxes = Axes.Both };
}
- protected override void Update()
+ protected override void LoadComplete()
{
- base.Update();
+ base.LoadComplete();
- while (slider.Path.ControlPoints.Length > pieces.Count)
- pieces.Add(new PathControlPointPiece(slider, pieces.Count));
- while (slider.Path.ControlPoints.Length < pieces.Count)
- pieces.Remove(pieces[pieces.Count - 1]);
+ inputManager = GetContainingInputManager();
+
+ controlPoints = slider.Path.ControlPoints.GetBoundCopy();
+ controlPoints.ItemsAdded += addControlPoints;
+ controlPoints.ItemsRemoved += removeControlPoints;
+
+ addControlPoints(controlPoints);
+ }
+
+ private void addControlPoints(IEnumerable controlPoints)
+ {
+ foreach (var point in controlPoints)
+ {
+ var piece = new PathControlPointPiece(slider, point);
+
+ if (allowSelection)
+ piece.RequestSelection = selectPiece;
+
+ Pieces.Add(piece);
+ }
+ }
+
+ private void removeControlPoints(IEnumerable controlPoints)
+ {
+ foreach (var point in controlPoints)
+ Pieces.RemoveAll(p => p.ControlPoint == point);
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ foreach (var piece in Pieces)
+ {
+ piece.IsSelected.Value = false;
+ }
+
+ return false;
+ }
+
+ public bool OnPressed(PlatformAction action)
+ {
+ switch (action.ActionMethod)
+ {
+ case PlatformActionMethod.Delete:
+ return deleteSelected();
+ }
+
+ return false;
+ }
+
+ public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
+
+ private void selectPiece(PathControlPointPiece piece, MouseButtonEvent e)
+ {
+ if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
+ piece.IsSelected.Toggle();
+ else
+ {
+ foreach (var p in Pieces)
+ p.IsSelected.Value = p == piece;
+ }
+ }
+
+ private bool deleteSelected()
+ {
+ List toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList();
+
+ // Ensure that there are any points to be deleted
+ if (toRemove.Count == 0)
+ return false;
+
+ RemoveControlPointsRequested?.Invoke(toRemove);
+
+ // Since pieces are re-used, they will not point to the deleted control points while remaining selected
+ foreach (var piece in Pieces)
+ piece.IsSelected.Value = false;
+
+ return true;
+ }
+
+ public MenuItem[] ContextMenuItems
+ {
+ get
+ {
+ if (!Pieces.Any(p => p.IsHovered))
+ return null;
+
+ var selectedPieces = Pieces.Where(p => p.IsSelected.Value).ToList();
+ int count = selectedPieces.Count;
+
+ if (count == 0)
+ return null;
+
+ List
-
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs
index 6c1882b4e2..28f5d4d301 100644
--- a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Tests.Beatmaps;
@@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
yield return new ConvertValue
{
StartTime = hitObject.StartTime,
- EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
+ EndTime = hitObject.GetEndTime(),
IsRim = hitObject is RimHit,
IsCentre = hitObject is CentreHit,
IsDrumRoll = hitObject is DrumRoll,
diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs
index cbbf5b0c09..8522a42739 100644
--- a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs
@@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
AddStep("Reset height", () => changePlayfieldSize(6));
var controlPointInfo = new ControlPointInfo();
- controlPointInfo.TimingPoints.Add(new TimingControlPoint());
+ controlPointInfo.Add(0, new TimingControlPoint());
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
{
@@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
var cpi = new ControlPointInfo();
- cpi.EffectPoints.Add(new EffectControlPoint { KiaiMode = kiai });
+ cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
Hit hit = new Hit();
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
@@ -157,7 +157,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
var cpi = new ControlPointInfo();
- cpi.EffectPoints.Add(new EffectControlPoint { KiaiMode = kiai });
+ cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
Hit hit = new Hit();
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
@@ -239,7 +239,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
private class TestStrongNestedHit : DrawableStrongNestedHit
{
public TestStrongNestedHit(DrawableHitObject mainObject)
- : base(null, mainObject)
+ : base(new StrongHitObject { StartTime = mainObject.HitObject.StartTime }, mainObject)
{
}
diff --git a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
index 717e795112..b5bd384e05 100644
--- a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
+++ b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs
index ad2596931d..aaf113f216 100644
--- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs
+++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs
@@ -19,12 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
{
this.controlPoints = controlPoints;
- IEnumerable samplePoints;
- if (controlPoints.SamplePoints.Count == 0)
- // Get the default sample point
- samplePoints = new[] { controlPoints.SamplePointAt(double.MinValue) };
- else
- samplePoints = controlPoints.SamplePoints;
+ IEnumerable samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints;
foreach (var s in samplePoints)
{
diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
index f0cf8d9c7d..10cc861b7e 100644
--- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
@@ -73,127 +73,133 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override IEnumerable ConvertHitObject(HitObject obj, IBeatmap beatmap)
{
- var distanceData = obj as IHasDistance;
- var repeatsData = obj as IHasRepeats;
- var endTimeData = obj as IHasEndTime;
- var curveData = obj as IHasCurve;
-
// Old osu! used hit sounding to determine various hit type information
- List samples = obj.Samples;
+ IList samples = obj.Samples;
bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
- if (distanceData != null)
+ switch (obj)
{
- // Number of spans of the object - one for the initial length and for each repeat
- int spans = repeatsData?.SpanCount() ?? 1;
-
- TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime);
- DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime);
-
- double speedAdjustment = difficultyPoint.SpeedMultiplier;
- double speedAdjustedBeatLength = timingPoint.BeatLength / speedAdjustment;
-
- // The true distance, accounting for any repeats. This ends up being the drum roll distance later
- double distance = distanceData.Distance * spans * legacy_velocity_multiplier;
-
- // The velocity of the taiko hit object - calculated as the velocity of a drum roll
- double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
- // The duration of the taiko hit object
- double taikoDuration = distance / taikoVelocity;
-
- // The velocity of the osu! hit object - calculated as the velocity of a slider
- double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
- // The duration of the osu! hit object
- double osuDuration = distance / osuVelocity;
-
- // osu-stable always uses the speed-adjusted beatlength to determine the velocities, but
- // only uses it for tick rate if beatmap version < 8
- if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
- speedAdjustedBeatLength *= speedAdjustment;
-
- // If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
- double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate, taikoDuration / spans);
-
- if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
+ case IHasDistance distanceData:
{
- List> allSamples = curveData != null ? curveData.NodeSamples : new List>(new[] { samples });
+ // Number of spans of the object - one for the initial length and for each repeat
+ int spans = (obj as IHasRepeats)?.SpanCount() ?? 1;
- int i = 0;
+ TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime);
+ DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime);
- for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
+ double speedAdjustment = difficultyPoint.SpeedMultiplier;
+ double speedAdjustedBeatLength = timingPoint.BeatLength / speedAdjustment;
+
+ // The true distance, accounting for any repeats. This ends up being the drum roll distance later
+ double distance = distanceData.Distance * spans * legacy_velocity_multiplier;
+
+ // The velocity of the taiko hit object - calculated as the velocity of a drum roll
+ double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
+ // The duration of the taiko hit object
+ double taikoDuration = distance / taikoVelocity;
+
+ // The velocity of the osu! hit object - calculated as the velocity of a slider
+ double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
+ // The duration of the osu! hit object
+ double osuDuration = distance / osuVelocity;
+
+ // osu-stable always uses the speed-adjusted beatlength to determine the velocities, but
+ // only uses it for tick rate if beatmap version < 8
+ if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
+ speedAdjustedBeatLength *= speedAdjustment;
+
+ // If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
+ double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate, taikoDuration / spans);
+
+ if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{
- List currentSamples = allSamples[i];
- bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
- strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
+ List> allSamples = obj is IHasCurve curveData ? curveData.NodeSamples : new List>(new[] { samples });
- if (isRim)
- {
- yield return new RimHit
- {
- StartTime = j,
- Samples = currentSamples,
- IsStrong = strong
- };
- }
- else
- {
- yield return new CentreHit
- {
- StartTime = j,
- Samples = currentSamples,
- IsStrong = strong
- };
- }
+ int i = 0;
- i = (i + 1) % allSamples.Count;
+ for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
+ {
+ IList currentSamples = allSamples[i];
+ bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
+ strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
+
+ if (isRim)
+ {
+ yield return new RimHit
+ {
+ StartTime = j,
+ Samples = currentSamples,
+ IsStrong = strong
+ };
+ }
+ else
+ {
+ yield return new CentreHit
+ {
+ StartTime = j,
+ Samples = currentSamples,
+ IsStrong = strong
+ };
+ }
+
+ i = (i + 1) % allSamples.Count;
+ }
}
- }
- else
- {
- yield return new DrumRoll
+ else
{
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- IsStrong = strong,
- Duration = taikoDuration,
- TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
- };
- }
- }
- else if (endTimeData != null)
- {
- double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
+ yield return new DrumRoll
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ IsStrong = strong,
+ Duration = taikoDuration,
+ TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
+ };
+ }
- yield return new Swell
- {
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- Duration = endTimeData.Duration,
- RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
- };
- }
- else
- {
- bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
-
- if (isRim)
- {
- yield return new RimHit
- {
- StartTime = obj.StartTime,
- Samples = obj.Samples,
- IsStrong = strong
- };
+ break;
}
- else
+
+ case IHasEndTime endTimeData:
{
- yield return new CentreHit
+ double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
+
+ yield return new Swell
{
StartTime = obj.StartTime,
Samples = obj.Samples,
- IsStrong = strong
+ Duration = endTimeData.Duration,
+ RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
};
+
+ break;
+ }
+
+ default:
+ {
+ bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
+
+ if (isRim)
+ {
+ yield return new RimHit
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ IsStrong = strong
+ };
+ }
+ else
+ {
+ yield return new CentreHit
+ {
+ StartTime = obj.StartTime,
+ Samples = obj.Samples,
+ IsStrong = strong
+ };
+ }
+
+ break;
}
}
}
diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs
index 70249db0f6..3a0fb64622 100644
--- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs
+++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs
@@ -31,10 +31,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
public override double Calculate(Dictionary categoryDifficulty = null)
{
mods = Score.Mods;
- countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
- countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
- countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
- countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
+ countGreat = Score.Statistics[HitResult.Great];
+ countGood = Score.Statistics[HitResult.Good];
+ countMeh = Score.Statistics[HitResult.Meh];
+ countMiss = Score.Statistics[HitResult.Miss];
// Don't count scores made with supposedly unranked mods
if (mods.Any(m => !m.Ranked))
@@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
double strainValue = Math.Pow(5.0 * Math.Max(1.0, Attributes.StarRating / 0.0075) - 4.0, 2.0) / 100000.0;
// Longer maps are worth more
- double lengthBonus = 1 + 0.1f * Math.Min(1.0, totalHits / 1500.0);
+ double lengthBonus = 1 + 0.1 * Math.Min(1.0, totalHits / 1500.0);
strainValue *= lengthBonus;
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
index 8e16a21199..338fd9e20f 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
@@ -1,17 +1,18 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
-using osuTK;
using osuTK.Graphics;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@@ -28,31 +29,18 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
///
private int rollingHits;
+ private readonly Container tickContainer;
+
+ private Color4 colourIdle;
+ private Color4 colourEngaged;
+
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
RelativeSizeAxes = Axes.Y;
-
- Container tickContainer;
MainPiece.Add(tickContainer = new Container { RelativeSizeAxes = Axes.Both });
-
- foreach (var tick in drumRoll.NestedHitObjects.OfType())
- {
- var newTick = new DrawableDrumRollTick(tick);
- newTick.OnNewResult += onNewTickResult;
-
- AddNested(newTick);
- tickContainer.Add(newTick);
- }
}
- protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
-
- public override bool OnPressed(TaikoAction action) => false;
-
- private Color4 colourIdle;
- private Color4 colourEngaged;
-
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -60,14 +48,57 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
colourEngaged = colours.YellowDarker;
}
- private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
+ protected override void LoadComplete()
{
+ base.LoadComplete();
+
+ OnNewResult += onNewResult;
+ }
+
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
+ {
+ base.AddNestedHitObject(hitObject);
+
+ switch (hitObject)
+ {
+ case DrawableDrumRollTick tick:
+ tickContainer.Add(tick);
+ break;
+ }
+ }
+
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ tickContainer.Clear();
+ }
+
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case DrumRollTick tick:
+ return new DrawableDrumRollTick(tick);
+ }
+
+ return base.CreateNestedHitObject(hitObject);
+ }
+
+ protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
+
+ public override bool OnPressed(TaikoAction action) => false;
+
+ private void onNewResult(DrawableHitObject obj, JudgementResult result)
+ {
+ if (!(obj is DrawableDrumRollTick))
+ return;
+
if (result.Type > HitResult.Miss)
rollingHits++;
else
rollingHits--;
- rollingHits = MathHelper.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
+ rollingHits = Math.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
MainPiece.FadeAccent(newColour, 100);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
index 07af7fe7e0..fa39819199 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@@ -11,9 +10,9 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
-using osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@@ -30,8 +29,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
///
private const double ring_appear_offset = 100;
- private readonly List ticks = new List();
-
+ private readonly Container ticks;
private readonly Container bodyContainer;
private readonly CircularContainer targetRing;
private readonly CircularContainer expandingRing;
@@ -108,16 +106,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
});
+ AddInternal(ticks = new Container { RelativeSizeAxes = Axes.Both });
+
MainPiece.Add(symbol = new SwellSymbolPiece());
-
- foreach (var tick in HitObject.NestedHitObjects.OfType())
- {
- var vis = new DrawableSwellTick(tick);
-
- ticks.Add(vis);
- AddInternal(vis);
- AddNested(vis);
- }
}
[BackgroundDependencyLoader]
@@ -136,11 +127,49 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Width *= Parent.RelativeChildSize.X;
}
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
+ {
+ base.AddNestedHitObject(hitObject);
+
+ switch (hitObject)
+ {
+ case DrawableSwellTick tick:
+ ticks.Add(tick);
+ break;
+ }
+ }
+
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ ticks.Clear();
+ }
+
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case SwellTick tick:
+ return new DrawableSwellTick(tick);
+ }
+
+ return base.CreateNestedHitObject(hitObject);
+ }
+
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (userTriggered)
{
- var nextTick = ticks.Find(j => !j.IsHit);
+ DrawableSwellTick nextTick = null;
+
+ foreach (var t in ticks)
+ {
+ if (!t.IsHit)
+ {
+ nextTick = t;
+ break;
+ }
+ }
nextTick?.TriggerResult(HitResult.Great);
@@ -149,7 +178,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
var completion = (float)numHits / HitObject.RequiredHits;
expandingRing
- .FadeTo(expandingRing.Alpha + MathHelper.Clamp(completion / 16, 0.1f, 0.6f), 50)
+ .FadeTo(expandingRing.Alpha + Math.Clamp(completion / 16, 0.1f, 0.6f), 50)
.Then()
.FadeTo(completion / 8, 2000, Easing.OutQuint);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
index 423f65b2d3..0db6498c12 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
@@ -11,6 +11,7 @@ using osu.Game.Audio;
using System.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
+using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@@ -109,11 +110,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
- protected readonly Vector2 BaseSize;
+ public new TaikoHitType HitObject;
+ protected readonly Vector2 BaseSize;
protected readonly TaikoPiece MainPiece;
- public new TaikoHitType HitObject;
+ private readonly Container strongHitContainer;
protected DrawableTaikoHitObject(TaikoHitType hitObject)
: base(hitObject)
@@ -129,17 +131,38 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Content.Add(MainPiece = CreateMainPiece());
MainPiece.KiaiMode = HitObject.Kiai;
- var strongObject = HitObject.NestedHitObjects.OfType().FirstOrDefault();
+ AddInternal(strongHitContainer = new Container());
+ }
- if (strongObject != null)
+ protected override void AddNestedHitObject(DrawableHitObject hitObject)
+ {
+ base.AddNestedHitObject(hitObject);
+
+ switch (hitObject)
{
- var strongHit = CreateStrongHit(strongObject);
-
- AddNested(strongHit);
- AddInternal(strongHit);
+ case DrawableStrongNestedHit strong:
+ strongHitContainer.Add(strong);
+ break;
}
}
+ protected override void ClearNestedHitObjects()
+ {
+ base.ClearNestedHitObjects();
+ strongHitContainer.Clear();
+ }
+
+ protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
+ {
+ switch (hitObject)
+ {
+ case StrongHitObject strong:
+ return CreateStrongHit(strong);
+ }
+
+ return base.CreateNestedHitObject(hitObject);
+ }
+
// Normal and clap samples are handled by the drum
protected override IEnumerable GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
index 773e3ae907..8067054f8f 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
@@ -10,27 +10,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
public class TaikoPiece : BeatSyncedContainer, IHasAccentColour
{
- private Color4 accentColour;
-
///
/// The colour of the inner circle and outer glows.
///
- public virtual Color4 AccentColour
- {
- get => accentColour;
- set => accentColour = value;
- }
-
- private bool kiaiMode;
+ public virtual Color4 AccentColour { get; set; }
///
/// Whether Kiai mode effects are enabled for this circle piece.
///
- public virtual bool KiaiMode
- {
- get => kiaiMode;
- set => kiaiMode = value;
- }
+ public virtual bool KiaiMode { get; set; }
public TaikoPiece()
{
diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs
index 299679b2c1..e61953aeb8 100644
--- a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs
+++ b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs
@@ -43,76 +43,83 @@ namespace osu.Game.Rulesets.Taiko.Replays
IHasEndTime endTimeData = h as IHasEndTime;
double endTime = endTimeData?.EndTime ?? h.StartTime;
- Swell swell = h as Swell;
- DrumRoll drumRoll = h as DrumRoll;
- Hit hit = h as Hit;
-
- if (swell != null)
+ switch (h)
{
- int d = 0;
- int count = 0;
- int req = swell.RequiredHits;
- double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);
-
- for (double j = h.StartTime; j < endTime; j += hitRate)
+ case Swell swell:
{
- TaikoAction action;
+ int d = 0;
+ int count = 0;
+ int req = swell.RequiredHits;
+ double hitRate = Math.Min(swell_hit_speed, swell.Duration / req);
- switch (d)
+ for (double j = h.StartTime; j < endTime; j += hitRate)
{
- default:
- case 0:
- action = TaikoAction.LeftCentre;
- break;
+ TaikoAction action;
- case 1:
- action = TaikoAction.LeftRim;
- break;
+ switch (d)
+ {
+ default:
+ case 0:
+ action = TaikoAction.LeftCentre;
+ break;
- case 2:
- action = TaikoAction.RightCentre;
- break;
+ case 1:
+ action = TaikoAction.LeftRim;
+ break;
- case 3:
- action = TaikoAction.RightRim;
+ case 2:
+ action = TaikoAction.RightCentre;
+ break;
+
+ case 3:
+ action = TaikoAction.RightRim;
+ break;
+ }
+
+ Frames.Add(new TaikoReplayFrame(j, action));
+ d = (d + 1) % 4;
+ if (++count == req)
break;
}
- Frames.Add(new TaikoReplayFrame(j, action));
- d = (d + 1) % 4;
- if (++count == req)
- break;
- }
- }
- else if (drumRoll != null)
- {
- foreach (var tick in drumRoll.NestedHitObjects.OfType())
- {
- Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
- hitButton = !hitButton;
- }
- }
- else if (hit != null)
- {
- TaikoAction[] actions;
-
- if (hit is CentreHit)
- {
- actions = h.IsStrong
- ? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
- : new[] { hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre };
- }
- else
- {
- actions = h.IsStrong
- ? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
- : new[] { hitButton ? TaikoAction.LeftRim : TaikoAction.RightRim };
+ break;
}
- Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
+ case DrumRoll drumRoll:
+ {
+ foreach (var tick in drumRoll.NestedHitObjects.OfType())
+ {
+ Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
+ hitButton = !hitButton;
+ }
+
+ break;
+ }
+
+ case Hit hit:
+ {
+ TaikoAction[] actions;
+
+ if (hit is CentreHit)
+ {
+ actions = h.IsStrong
+ ? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
+ : new[] { hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre };
+ }
+ else
+ {
+ actions = h.IsStrong
+ ? new[] { TaikoAction.LeftRim, TaikoAction.RightRim }
+ : new[] { hitButton ? TaikoAction.LeftRim : TaikoAction.RightRim };
+ }
+
+ Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
+ break;
+ }
+
+ default:
+ throw new InvalidOperationException("Unknown hit object type.");
}
- else
- throw new InvalidOperationException("Unknown hit object type.");
var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button
diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs
index 84464b199e..980f5ea340 100644
--- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs
+++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI;
using osuTK;
@@ -22,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{
base.Update();
- float aspectAdjust = MathHelper.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
+ float aspectAdjust = Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
Size = new Vector2(1, default_relative_height * aspectAdjust);
}
}
diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj
index 656ebcc7c2..ebed8c6d7c 100644
--- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj
+++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj
@@ -1,9 +1,7 @@
-
- netstandard2.0
+ netstandard2.1
Library
- AnyCPU
true
bash the drum. to the beat.
diff --git a/osu.Game.Tests.Android/Properties/AndroidManifest.xml b/osu.Game.Tests.Android/Properties/AndroidManifest.xml
index bb996dc5ca..4a63f0c357 100644
--- a/osu.Game.Tests.Android/Properties/AndroidManifest.xml
+++ b/osu.Game.Tests.Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/osu.Game.Tests.Android/osu.Game.Tests.Android.csproj b/osu.Game.Tests.Android/osu.Game.Tests.Android.csproj
index c2dd194e09..c44ed69c4d 100644
--- a/osu.Game.Tests.Android/osu.Game.Tests.Android.csproj
+++ b/osu.Game.Tests.Android/osu.Game.Tests.Android.csproj
@@ -24,6 +24,7 @@
%(RecursiveDir)%(Filename)%(Extension)
+
%(RecursiveDir)%(Filename)%(Extension)
@@ -68,10 +69,5 @@
osu.Game
-
-
- 2.0.0
-
-
\ No newline at end of file
diff --git a/osu.Game.Tests.iOS/osu.Game.Tests.iOS.csproj b/osu.Game.Tests.iOS/osu.Game.Tests.iOS.csproj
index 5c0713b895..ca68369ebb 100644
--- a/osu.Game.Tests.iOS/osu.Game.Tests.iOS.csproj
+++ b/osu.Game.Tests.iOS/osu.Game.Tests.iOS.csproj
@@ -1,6 +1,5 @@
-
+
-
Debug
iPhoneSimulator
@@ -48,5 +47,4 @@
-
\ No newline at end of file
diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
index de516d3142..26e70f19e4 100644
--- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
@@ -167,9 +167,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
var controlPoints = beatmap.ControlPointInfo;
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
- Assert.AreEqual(42, controlPoints.DifficultyPoints.Count);
- Assert.AreEqual(42, controlPoints.SamplePoints.Count);
- Assert.AreEqual(42, controlPoints.EffectPoints.Count);
+ Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
+ Assert.AreEqual(34, controlPoints.SamplePoints.Count);
+ Assert.AreEqual(8, controlPoints.EffectPoints.Count);
var timingPoint = controlPoints.TimingPointAt(0);
Assert.AreEqual(956, timingPoint.Time);
@@ -191,7 +191,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
difficultyPoint = controlPoints.DifficultyPointAt(48428);
- Assert.AreEqual(48428, difficultyPoint.Time);
+ Assert.AreEqual(0, difficultyPoint.Time);
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
difficultyPoint = controlPoints.DifficultyPointAt(116999);
@@ -224,7 +224,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsFalse(effectPoint.OmitFirstBarLine);
effectPoint = controlPoints.EffectPointAt(119637);
- Assert.AreEqual(119637, effectPoint.Time);
+ Assert.AreEqual(95901, effectPoint.Time);
Assert.IsFalse(effectPoint.KiaiMode);
Assert.IsFalse(effectPoint.OmitFirstBarLine);
}
@@ -262,6 +262,21 @@ namespace osu.Game.Tests.Beatmaps.Formats
}
}
+ [Test]
+ public void TestTimingPointResetsSpeedMultiplier()
+ {
+ var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
+
+ using (var resStream = TestResources.OpenResource("timingpoint-speedmultiplier-reset.osu"))
+ using (var stream = new LineBufferedReader(resStream))
+ {
+ var controlPoints = decoder.Decode(stream).ControlPointInfo;
+
+ Assert.That(controlPoints.DifficultyPointAt(0).SpeedMultiplier, Is.EqualTo(0.5).Within(0.1));
+ Assert.That(controlPoints.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1).Within(0.1));
+ }
+ }
+
[Test]
public void TestDecodeBeatmapColours()
{
@@ -362,6 +377,23 @@ namespace osu.Game.Tests.Beatmaps.Formats
}
}
+ [Test]
+ public void TestDecodeControlPointDifficultyChange()
+ {
+ var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
+
+ using (var resStream = TestResources.OpenResource("controlpoint-difficulty-multiplier.osu"))
+ using (var stream = new LineBufferedReader(resStream))
+ {
+ var controlPointInfo = decoder.Decode(stream).ControlPointInfo;
+
+ Assert.That(controlPointInfo.DifficultyPointAt(5).SpeedMultiplier, Is.EqualTo(1));
+ Assert.That(controlPointInfo.DifficultyPointAt(1000).SpeedMultiplier, Is.EqualTo(10));
+ Assert.That(controlPointInfo.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1.8518518518518519d));
+ Assert.That(controlPointInfo.DifficultyPointAt(3000).SpeedMultiplier, Is.EqualTo(0.5));
+ }
+ }
+
[Test]
public void TestDecodeControlPointCustomSampleBank()
{
@@ -381,7 +413,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
}
- HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
+ static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
}
[Test]
@@ -399,7 +431,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
}
- HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
+ static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
}
[Test]
@@ -419,7 +451,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
}
- HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
+ static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
}
[Test]
diff --git a/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs b/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs
index b3863bcf44..669acc3202 100644
--- a/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/ParsingTest.cs
@@ -59,7 +59,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
{
try
{
- var _ = int.Parse(input);
+ _ = int.Parse(input);
}
catch (Exception e)
{
diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
index 4e81954f50..4766411cbd 100644
--- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
+++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
@@ -411,6 +411,48 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
+ [Test]
+ public async Task TestImportWithDuplicateHashes()
+ {
+ using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportNestedStructure)))
+ {
+ try
+ {
+ var osu = loadOsu(host);
+
+ var temp = TestResources.GetTestBeatmapForImport();
+
+ string extractedFolder = $"{temp}_extracted";
+ Directory.CreateDirectory(extractedFolder);
+
+ try
+ {
+ using (var zip = ZipArchive.Open(temp))
+ zip.WriteToDirectory(extractedFolder);
+
+ using (var zip = ZipArchive.Create())
+ {
+ zip.AddAllFromDirectory(extractedFolder);
+ zip.AddEntry("duplicate.osu", Directory.GetFiles(extractedFolder, "*.osu").First());
+ zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
+ }
+
+ await osu.Dependencies.Get().Import(temp);
+
+ ensureLoaded(osu);
+ }
+ finally
+ {
+ Directory.Delete(extractedFolder, true);
+ }
+ }
+ finally
+ {
+ host.Exit();
+ }
+ }
+ }
+
[Test]
public async Task TestImportNestedStructure()
{
diff --git a/osu.Game.Tests/Chat/MessageFormatterTests.cs b/osu.Game.Tests/Chat/MessageFormatterTests.cs
index 9b4a90e9a9..fbb0416c45 100644
--- a/osu.Game.Tests/Chat/MessageFormatterTests.cs
+++ b/osu.Game.Tests/Chat/MessageFormatterTests.cs
@@ -273,6 +273,96 @@ namespace osu.Game.Tests.Chat
Assert.AreEqual(21, result.Links[0].Length);
}
+ [Test]
+ public void TestMarkdownFormatLinkWithInlineTitle()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"osu!\") before..." });
+
+ Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
+ Assert.AreEqual(15, result.Links[0].Index);
+ Assert.AreEqual(16, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkWithInlineTitleAndEscapedQuotes()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"inner quote \\\" just to confuse \") before..." });
+
+ Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
+ Assert.AreEqual(15, result.Links[0].Index);
+ Assert.AreEqual(16, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkWithUrlInTextAndInlineTitle()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://osu.ppy.sh](https://osu.ppy.sh \"https://osu.ppy.sh\") before..." });
+
+ Assert.AreEqual("I haven't seen https://osu.ppy.sh before...", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
+ Assert.AreEqual(15, result.Links[0].Index);
+ Assert.AreEqual(18, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkWithUrlAndTextInTitle()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [oh no, text here! https://osu.ppy.sh](https://osu.ppy.sh) before..." });
+
+ Assert.AreEqual("I haven't seen oh no, text here! https://osu.ppy.sh before...", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
+ Assert.AreEqual(15, result.Links[0].Index);
+ Assert.AreEqual(36, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkWithMisleadingUrlInText()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://google.com](https://osu.ppy.sh) before..." });
+
+ Assert.AreEqual("I haven't seen https://google.com before...", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
+ Assert.AreEqual(15, result.Links[0].Index);
+ Assert.AreEqual(18, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkThatContractsIntoLargerLink()
+ {
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "super broken https://[osu.ppy](https://reddit.com).sh/" });
+
+ Assert.AreEqual("super broken https://osu.ppy.sh/", result.DisplayContent);
+ Assert.AreEqual(1, result.Links.Count);
+ Assert.AreEqual("https://reddit.com", result.Links[0].Url);
+ Assert.AreEqual(21, result.Links[0].Index);
+ Assert.AreEqual(7, result.Links[0].Length);
+ }
+
+ [Test]
+ public void TestMarkdownFormatLinkDirectlyNextToRawLink()
+ {
+ // the raw link has a port at the end of it, so that the raw link regex terminates at the port and doesn't consume display text from the formatted one
+ Message result = MessageFormatter.FormatMessage(new Message { Content = "https://localhost:8080[https://osu.ppy.sh](https://osu.ppy.sh) should be two links" });
+
+ Assert.AreEqual("https://localhost:8080https://osu.ppy.sh should be two links", result.DisplayContent);
+ Assert.AreEqual(2, result.Links.Count);
+
+ Assert.AreEqual("https://localhost:8080", result.Links[0].Url);
+ Assert.AreEqual(0, result.Links[0].Index);
+ Assert.AreEqual(22, result.Links[0].Length);
+
+ Assert.AreEqual("https://osu.ppy.sh", result.Links[1].Url);
+ Assert.AreEqual(22, result.Links[1].Index);
+ Assert.AreEqual(18, result.Links[1].Length);
+ }
+
[Test]
public void TestChannelLink()
{
diff --git a/osu.Game.Tests/Editor/TestSceneHitObjectComposerDistanceSnapping.cs b/osu.Game.Tests/Editor/TestSceneHitObjectComposerDistanceSnapping.cs
new file mode 100644
index 0000000000..fe3cc375ea
--- /dev/null
+++ b/osu.Game.Tests/Editor/TestSceneHitObjectComposerDistanceSnapping.cs
@@ -0,0 +1,194 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Edit;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osu.Game.Tests.Visual;
+
+namespace osu.Game.Tests.Editor
+{
+ [HeadlessTest]
+ public class TestSceneHitObjectComposerDistanceSnapping : EditorClockTestScene
+ {
+ private TestHitObjectComposer composer;
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ Child = composer = new TestHitObjectComposer();
+
+ BeatDivisor.Value = 1;
+
+ composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 1 });
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 });
+ });
+
+ [TestCase(1)]
+ [TestCase(2)]
+ public void TestSliderMultiplier(float multiplier)
+ {
+ AddStep($"set multiplier = {multiplier}", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = multiplier);
+
+ assertSnapDistance(100 * multiplier);
+ }
+
+ [TestCase(1)]
+ [TestCase(2)]
+ public void TestSpeedMultiplier(float multiplier)
+ {
+ AddStep($"set multiplier = {multiplier}", () =>
+ {
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = multiplier });
+ });
+
+ assertSnapDistance(100 * multiplier);
+ }
+
+ [TestCase(1)]
+ [TestCase(2)]
+ public void TestBeatDivisor(int divisor)
+ {
+ AddStep($"set divisor = {divisor}", () => BeatDivisor.Value = divisor);
+
+ assertSnapDistance(100f / divisor);
+ }
+
+ [Test]
+ public void TestConvertDurationToDistance()
+ {
+ assertDurationToDistance(500, 50);
+ assertDurationToDistance(1000, 100);
+
+ AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
+
+ assertDurationToDistance(500, 100);
+ assertDurationToDistance(1000, 200);
+
+ AddStep("set beat length = 500", () =>
+ {
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
+ });
+
+ assertDurationToDistance(500, 200);
+ assertDurationToDistance(1000, 400);
+ }
+
+ [Test]
+ public void TestConvertDistanceToDuration()
+ {
+ assertDistanceToDuration(50, 500);
+ assertDistanceToDuration(100, 1000);
+
+ AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
+
+ assertDistanceToDuration(100, 500);
+ assertDistanceToDuration(200, 1000);
+
+ AddStep("set beat length = 500", () =>
+ {
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
+ });
+
+ assertDistanceToDuration(200, 500);
+ assertDistanceToDuration(400, 1000);
+ }
+
+ [Test]
+ public void TestGetSnappedDurationFromDistance()
+ {
+ assertSnappedDuration(50, 0);
+ assertSnappedDuration(100, 1000);
+ assertSnappedDuration(150, 1000);
+ assertSnappedDuration(200, 2000);
+ assertSnappedDuration(250, 2000);
+
+ AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
+
+ assertSnappedDuration(50, 0);
+ assertSnappedDuration(100, 0);
+ assertSnappedDuration(150, 0);
+ assertSnappedDuration(200, 1000);
+ assertSnappedDuration(250, 1000);
+
+ AddStep("set beat length = 500", () =>
+ {
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
+ });
+
+ assertSnappedDuration(50, 0);
+ assertSnappedDuration(100, 0);
+ assertSnappedDuration(150, 0);
+ assertSnappedDuration(200, 500);
+ assertSnappedDuration(250, 500);
+ assertSnappedDuration(400, 1000);
+ }
+
+ [Test]
+ public void GetSnappedDistanceFromDistance()
+ {
+ assertSnappedDistance(50, 0);
+ assertSnappedDistance(100, 100);
+ assertSnappedDistance(150, 100);
+ assertSnappedDistance(200, 200);
+ assertSnappedDistance(250, 200);
+
+ AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
+
+ assertSnappedDistance(50, 0);
+ assertSnappedDistance(100, 0);
+ assertSnappedDistance(150, 0);
+ assertSnappedDistance(200, 200);
+ assertSnappedDistance(250, 200);
+
+ AddStep("set beat length = 500", () =>
+ {
+ composer.EditorBeatmap.ControlPointInfo.Clear();
+ composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
+ });
+
+ assertSnappedDistance(50, 0);
+ assertSnappedDistance(100, 0);
+ assertSnappedDistance(150, 0);
+ assertSnappedDistance(200, 200);
+ assertSnappedDistance(250, 200);
+ assertSnappedDistance(400, 400);
+ }
+
+ private void assertSnapDistance(float expectedDistance)
+ => AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(0) == expectedDistance);
+
+ private void assertDurationToDistance(double duration, float expectedDistance)
+ => AddAssert($"duration = {duration} -> distance = {expectedDistance}", () => composer.DurationToDistance(0, duration) == expectedDistance);
+
+ private void assertDistanceToDuration(float distance, double expectedDuration)
+ => AddAssert($"distance = {distance} -> duration = {expectedDuration}", () => composer.DistanceToDuration(0, distance) == expectedDuration);
+
+ private void assertSnappedDuration(float distance, double expectedDuration)
+ => AddAssert($"distance = {distance} -> duration = {expectedDuration} (snapped)", () => composer.GetSnappedDurationFromDistance(0, distance) == expectedDuration);
+
+ private void assertSnappedDistance(float distance, float expectedDistance)
+ => AddAssert($"distance = {distance} -> distance = {expectedDistance} (snapped)", () => composer.GetSnappedDistanceFromDistance(0, distance) == expectedDistance);
+
+ private class TestHitObjectComposer : OsuHitObjectComposer
+ {
+ public new EditorBeatmap EditorBeatmap => base.EditorBeatmap;
+
+ public TestHitObjectComposer()
+ : base(new OsuRuleset())
+ {
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs
new file mode 100644
index 0000000000..6d7159a825
--- /dev/null
+++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs
@@ -0,0 +1,143 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Audio.Sample;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Textures;
+using osu.Framework.Testing;
+using osu.Game.Audio;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Objects.Types;
+using osu.Game.Skinning;
+using osu.Game.Tests.Visual;
+using osuTK.Graphics;
+
+namespace osu.Game.Tests.Gameplay
+{
+ [HeadlessTest]
+ public class TestSceneHitObjectAccentColour : OsuTestScene
+ {
+ private Container skinContainer;
+
+ [SetUp]
+ public void Setup() => Schedule(() => Child = skinContainer = new SkinProvidingContainer(new TestSkin()));
+
+ [Test]
+ public void TestChangeComboIndexBeforeLoad()
+ {
+ TestDrawableHitObject hitObject = null;
+
+ AddStep("set combo and add hitobject", () =>
+ {
+ hitObject = new TestDrawableHitObject();
+ hitObject.HitObject.ComboIndex = 1;
+
+ skinContainer.Add(hitObject);
+ });
+
+ AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
+ }
+
+ [Test]
+ public void TestChangeComboIndexDuringLoad()
+ {
+ TestDrawableHitObject hitObject = null;
+
+ AddStep("add hitobject and set combo", () =>
+ {
+ skinContainer.Add(hitObject = new TestDrawableHitObject());
+ hitObject.HitObject.ComboIndex = 1;
+ });
+
+ AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
+ }
+
+ [Test]
+ public void TestChangeComboIndexAfterLoad()
+ {
+ TestDrawableHitObject hitObject = null;
+
+ AddStep("add hitobject", () => skinContainer.Add(hitObject = new TestDrawableHitObject()));
+ AddAssert("combo colour is red", () => hitObject.AccentColour.Value == Color4.Red);
+
+ AddStep("change combo", () => hitObject.HitObject.ComboIndex = 1);
+ AddAssert("combo colour is green", () => hitObject.AccentColour.Value == Color4.Green);
+ }
+
+ private class TestDrawableHitObject : DrawableHitObject
+ {
+ public TestDrawableHitObject()
+ : base(new TestHitObjectWithCombo())
+ {
+ }
+ }
+
+ private class TestHitObjectWithCombo : HitObject, IHasComboInformation
+ {
+ public bool NewCombo { get; } = false;
+ public int ComboOffset { get; } = 0;
+
+ public Bindable IndexInCurrentComboBindable { get; } = new Bindable();
+
+ public int IndexInCurrentCombo
+ {
+ get => IndexInCurrentComboBindable.Value;
+ set => IndexInCurrentComboBindable.Value = value;
+ }
+
+ public Bindable ComboIndexBindable { get; } = new Bindable();
+
+ public int ComboIndex
+ {
+ get => ComboIndexBindable.Value;
+ set => ComboIndexBindable.Value = value;
+ }
+
+ public Bindable LastInComboBindable { get; } = new Bindable();
+
+ public bool LastInCombo
+ {
+ get => LastInComboBindable.Value;
+ set => LastInComboBindable.Value = value;
+ }
+ }
+
+ private class TestSkin : ISkin
+ {
+ public readonly List ComboColours = new List
+ {
+ Color4.Red,
+ Color4.Green
+ };
+
+ public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotImplementedException();
+
+ public Texture GetTexture(string componentName) => throw new NotImplementedException();
+
+ public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
+
+ public IBindable GetConfig(TLookup lookup)
+ {
+ switch (lookup)
+ {
+ case GlobalSkinConfiguration global:
+ switch (global)
+ {
+ case GlobalSkinConfiguration.ComboColours:
+ return SkinUtils.As(new Bindable>(ComboColours));
+ }
+
+ break;
+ }
+
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
new file mode 100644
index 0000000000..42a3b4cf43
--- /dev/null
+++ b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
@@ -0,0 +1,48 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Game.Beatmaps;
+
+namespace osu.Game.Tests.NonVisual
+{
+ [TestFixture]
+ public class BeatmapSetInfoEqualityTest
+ {
+ [Test]
+ public void TestOnlineWithOnline()
+ {
+ var ourInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 123 };
+ var otherInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 123 };
+
+ Assert.AreEqual(ourInfo, otherInfo);
+ }
+
+ [Test]
+ public void TestDatabasedWithDatabased()
+ {
+ var ourInfo = new BeatmapSetInfo { ID = 123 };
+ var otherInfo = new BeatmapSetInfo { ID = 123 };
+
+ Assert.AreEqual(ourInfo, otherInfo);
+ }
+
+ [Test]
+ public void TestDatabasedWithOnline()
+ {
+ var ourInfo = new BeatmapSetInfo { ID = 123, OnlineBeatmapSetID = 12 };
+ var otherInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 12 };
+
+ Assert.AreEqual(ourInfo, otherInfo);
+ }
+
+ [Test]
+ public void TestCheckNullID()
+ {
+ var ourInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Loved };
+ var otherInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Approved };
+
+ Assert.AreNotEqual(ourInfo, otherInfo);
+ }
+ }
+}
diff --git a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
new file mode 100644
index 0000000000..a51b90851c
--- /dev/null
+++ b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
@@ -0,0 +1,227 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Game.Beatmaps.ControlPoints;
+
+namespace osu.Game.Tests.NonVisual
+{
+ [TestFixture]
+ public class ControlPointInfoTest
+ {
+ [Test]
+ public void TestAdd()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new TimingControlPoint());
+ cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(2));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(2));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2));
+ }
+
+ [Test]
+ public void TestAddRedundantTiming()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new TimingControlPoint()); // is *not* redundant, special exception for first timing point.
+ cpi.Add(1000, new TimingControlPoint()); // is redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestAddRedundantDifficulty()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new DifficultyControlPoint()); // is redundant
+ cpi.Add(1000, new DifficultyControlPoint()); // is redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(0));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
+
+ cpi.Add(1000, new DifficultyControlPoint { SpeedMultiplier = 2 }); // is not redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestAddRedundantSample()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new SampleControlPoint()); // is redundant
+ cpi.Add(1000, new SampleControlPoint()); // is redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(0));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
+
+ cpi.Add(1000, new SampleControlPoint { SampleVolume = 50 }); // is not redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ Assert.That(cpi.SamplePoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestAddRedundantEffect()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new EffectControlPoint()); // is redundant
+ cpi.Add(1000, new EffectControlPoint()); // is redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(0));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
+
+ cpi.Add(1000, new EffectControlPoint { KiaiMode = true }); // is not redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ Assert.That(cpi.EffectPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestAddGroup()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(1000, true);
+ var group2 = cpi.GroupAt(1000, true);
+
+ Assert.That(group, Is.EqualTo(group2));
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestGroupAtLookupOnly()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(5000, true);
+ Assert.That(group, Is.Not.Null);
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+ Assert.That(cpi.GroupAt(1000), Is.Null);
+ Assert.That(cpi.GroupAt(5000), Is.Not.Null);
+ }
+
+ [Test]
+ public void TestAddRemoveGroup()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(1000, true);
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+
+ cpi.RemoveGroup(group);
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void TestAddControlPointToGroup()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(1000, true);
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+
+ // usually redundant, but adding to group forces it to be added
+ group.Add(new DifficultyControlPoint());
+
+ Assert.That(group.ControlPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
+ }
+
+ [Test]
+ public void TestAddDuplicateControlPointToGroup()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(1000, true);
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+
+ group.Add(new DifficultyControlPoint());
+ group.Add(new DifficultyControlPoint { SpeedMultiplier = 2 });
+
+ Assert.That(group.ControlPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
+ Assert.That(cpi.DifficultyPoints.First().SpeedMultiplier, Is.EqualTo(2));
+ }
+
+ [Test]
+ public void TestRemoveControlPointFromGroup()
+ {
+ var cpi = new ControlPointInfo();
+
+ var group = cpi.GroupAt(1000, true);
+ Assert.That(cpi.Groups.Count, Is.EqualTo(1));
+
+ var difficultyPoint = new DifficultyControlPoint();
+
+ group.Add(difficultyPoint);
+ group.Remove(difficultyPoint);
+
+ Assert.That(group.ControlPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void TestOrdering()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new TimingControlPoint());
+ cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
+ cpi.Add(10000, new TimingControlPoint { BeatLength = 200 });
+ cpi.Add(5000, new TimingControlPoint { BeatLength = 100 });
+ cpi.Add(3000, new DifficultyControlPoint { SpeedMultiplier = 2 });
+ cpi.GroupAt(7000, true).Add(new DifficultyControlPoint { SpeedMultiplier = 4 });
+ cpi.GroupAt(1000).Add(new SampleControlPoint { SampleVolume = 0 });
+ cpi.GroupAt(8000, true).Add(new EffectControlPoint { KiaiMode = true });
+
+ Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(8));
+
+ Assert.That(cpi.Groups, Is.Ordered.Ascending.By(nameof(ControlPointGroup.Time)));
+
+ Assert.That(cpi.AllControlPoints, Is.Ordered.Ascending.By(nameof(ControlPoint.Time)));
+ Assert.That(cpi.TimingPoints, Is.Ordered.Ascending.By(nameof(ControlPoint.Time)));
+ }
+
+ [Test]
+ public void TestClear()
+ {
+ var cpi = new ControlPointInfo();
+
+ cpi.Add(0, new TimingControlPoint());
+ cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
+ cpi.Add(10000, new TimingControlPoint { BeatLength = 200 });
+ cpi.Add(5000, new TimingControlPoint { BeatLength = 100 });
+ cpi.Add(3000, new DifficultyControlPoint { SpeedMultiplier = 2 });
+ cpi.GroupAt(7000, true).Add(new DifficultyControlPoint { SpeedMultiplier = 4 });
+ cpi.GroupAt(1000).Add(new SampleControlPoint { SampleVolume = 0 });
+ cpi.GroupAt(8000, true).Add(new EffectControlPoint { KiaiMode = true });
+
+ cpi.Clear();
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(0));
+ Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(0));
+ Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(0));
+ }
+ }
+}
diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs
index 9869ddde41..7b2913b817 100644
--- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs
+++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs
@@ -87,7 +87,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
Assert.IsNull(filterCriteria.BPM.Max);
}
- private static object[] lengthQueryExamples =
+ private static readonly object[] length_query_examples =
{
new object[] { "6ms", TimeSpan.FromMilliseconds(6), TimeSpan.FromMilliseconds(1) },
new object[] { "23s", TimeSpan.FromSeconds(23), TimeSpan.FromSeconds(1) },
@@ -97,7 +97,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
};
[Test]
- [TestCaseSource(nameof(lengthQueryExamples))]
+ [TestCaseSource(nameof(length_query_examples))]
public void TestApplyLengthQueries(string lengthQuery, TimeSpan expectedLength, TimeSpan scale)
{
string query = $"length={lengthQuery} time";
diff --git a/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs b/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs
index 18cbd4e7c5..7df7df22ea 100644
--- a/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs
+++ b/osu.Game.Tests/NonVisual/FramedReplayInputHandlerTest.cs
@@ -225,8 +225,10 @@ namespace osu.Game.Tests.NonVisual
private void fastForwardToPoint(double destination)
{
for (int i = 0; i < 1000; i++)
+ {
if (handler.SetFrameFromTime(destination) == null)
return;
+ }
throw new TimeoutException("Seek was never fulfilled");
}
diff --git a/osu.Game.Tests/Resources/controlpoint-difficulty-multiplier.osu b/osu.Game.Tests/Resources/controlpoint-difficulty-multiplier.osu
new file mode 100644
index 0000000000..5f06fc33c8
--- /dev/null
+++ b/osu.Game.Tests/Resources/controlpoint-difficulty-multiplier.osu
@@ -0,0 +1,8 @@
+osu file format v7
+
+[TimingPoints]
+0,100,4,2,0,100,1,0
+12,500,4,2,0,100,1,0
+1000,-10,4,2,0,100,0,0
+2000,-54,4,2,0,100,0,0
+3000,-200,4,2,0,100,0,0
diff --git a/osu.Game.Tests/Resources/skin-20.ini b/osu.Game.Tests/Resources/skin-20.ini
new file mode 100644
index 0000000000..947b56b2f9
--- /dev/null
+++ b/osu.Game.Tests/Resources/skin-20.ini
@@ -0,0 +1,2 @@
+[General]
+Version: 2
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/skin-latest.ini b/osu.Game.Tests/Resources/skin-latest.ini
new file mode 100644
index 0000000000..32f500263f
--- /dev/null
+++ b/osu.Game.Tests/Resources/skin-latest.ini
@@ -0,0 +1,2 @@
+[General]
+Version: latest
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/timingpoint-speedmultiplier-reset.osu b/osu.Game.Tests/Resources/timingpoint-speedmultiplier-reset.osu
new file mode 100644
index 0000000000..4512903c68
--- /dev/null
+++ b/osu.Game.Tests/Resources/timingpoint-speedmultiplier-reset.osu
@@ -0,0 +1,5 @@
+osu file format v14
+
+[TimingPoints]
+0,-200,4,1,0,100,0,0
+2000,100,1,1,0,100,1,0
diff --git a/osu.Game.Tests/Scores/IO/TestScoreEquality.cs b/osu.Game.Tests/Scores/IO/TestScoreEquality.cs
new file mode 100644
index 0000000000..d1374eb6e5
--- /dev/null
+++ b/osu.Game.Tests/Scores/IO/TestScoreEquality.cs
@@ -0,0 +1,73 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Game.Scoring;
+
+namespace osu.Game.Tests.Scores.IO
+{
+ [TestFixture]
+ public class TestScoreEquality
+ {
+ [Test]
+ public void TestNonMatchingByReference()
+ {
+ ScoreInfo score1 = new ScoreInfo();
+ ScoreInfo score2 = new ScoreInfo();
+
+ Assert.That(score1, Is.Not.EqualTo(score2));
+ }
+
+ [Test]
+ public void TestMatchingByReference()
+ {
+ ScoreInfo score = new ScoreInfo();
+
+ Assert.That(score, Is.EqualTo(score));
+ }
+
+ [Test]
+ public void TestNonMatchingByPrimaryKey()
+ {
+ ScoreInfo score1 = new ScoreInfo { ID = 1 };
+ ScoreInfo score2 = new ScoreInfo { ID = 2 };
+
+ Assert.That(score1, Is.Not.EqualTo(score2));
+ }
+
+ [Test]
+ public void TestMatchingByPrimaryKey()
+ {
+ ScoreInfo score1 = new ScoreInfo { ID = 1 };
+ ScoreInfo score2 = new ScoreInfo { ID = 1 };
+
+ Assert.That(score1, Is.EqualTo(score2));
+ }
+
+ [Test]
+ public void TestNonMatchingByHash()
+ {
+ ScoreInfo score1 = new ScoreInfo { Hash = "a" };
+ ScoreInfo score2 = new ScoreInfo { Hash = "b" };
+
+ Assert.That(score1, Is.Not.EqualTo(score2));
+ }
+
+ [Test]
+ public void TestMatchingByHash()
+ {
+ ScoreInfo score1 = new ScoreInfo { Hash = "a" };
+ ScoreInfo score2 = new ScoreInfo { Hash = "a" };
+
+ Assert.That(score1, Is.EqualTo(score2));
+ }
+
+ [Test]
+ public void TestNonMatchingByNull()
+ {
+ ScoreInfo score = new ScoreInfo();
+
+ Assert.That(score, Is.Not.EqualTo(null));
+ }
+ }
+}
diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
index 0d96dd08da..f68d49dd3e 100644
--- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
+++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
@@ -25,7 +25,9 @@ namespace osu.Game.Tests.Skins
var comboColors = decoder.Decode(stream).ComboColours;
List expectedColors;
+
if (hasColours)
+ {
expectedColors = new List
{
new Color4(142, 199, 255, 255),
@@ -33,6 +35,7 @@ namespace osu.Game.Tests.Skins
new Color4(128, 255, 255, 255),
new Color4(100, 100, 100, 100),
};
+ }
else
expectedColors = new DefaultSkin().Configuration.ComboColours;
@@ -56,5 +59,32 @@ namespace osu.Game.Tests.Skins
Assert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]);
}
}
+
+ [Test]
+ public void TestDecodeSpecifiedVersion()
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource("skin-20.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
+ }
+
+ [Test]
+ public void TestDecodeLatestVersion()
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource("skin-latest.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
+ }
+
+ [Test]
+ public void TestDecodeNoVersion()
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource("skin-empty.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.IsNull(decoder.Decode(stream).LegacyVersion);
+ }
}
}
diff --git a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs
index 578030748b..8b9c648442 100644
--- a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs
+++ b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs
@@ -116,6 +116,14 @@ namespace osu.Game.Tests.Skins
});
}
+ [Test]
+ public void TestLegacyVersionLookup()
+ {
+ AddStep("Set source1 version 2.3", () => source1.Configuration.LegacyVersion = 2.3m);
+ AddStep("Set source2 version null", () => source2.Configuration.LegacyVersion = null);
+ AddAssert("Check legacy version lookup", () => requester.GetConfig(LegacySkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
+ }
+
public enum LookupType
{
Test
diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
index 3061a3a542..8f71584b4d 100644
--- a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
+++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
@@ -209,9 +209,10 @@ namespace osu.Game.Tests.Visual.Background
public void TransitionTest()
{
performFullSetup();
- var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } });
- AddStep("Transition to Results", () => player.Push(results));
- AddUntilStep("Wait for results is current", results.IsCurrentScreen);
+ FadeAccessibleResults results = null;
+ AddStep("Transition to Results", () => player.Push(results =
+ new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
+ AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
waitForDim();
AddAssert("Screen is undimmed, original background retained", () =>
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
@@ -285,6 +286,12 @@ namespace osu.Game.Tests.Visual.Background
});
}
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ rulesets?.Dispose();
+ }
+
private class DummySongSelect : PlaySongSelect
{
protected override BackgroundScreen CreateBackground()
diff --git a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs
index df6740421b..d76905dab8 100644
--- a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs
+++ b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs
@@ -3,16 +3,20 @@
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps;
+using static osu.Game.Tests.Visual.Components.TestScenePreviewTrackManager.TestPreviewTrackManager;
namespace osu.Game.Tests.Visual.Components
{
public class TestScenePreviewTrackManager : OsuTestScene, IPreviewTrackOwner
{
- private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager();
+ private readonly TestPreviewTrackManager trackManager = new TestPreviewTrackManager();
+
+ private AudioManager audio;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
@@ -23,8 +27,10 @@ namespace osu.Game.Tests.Visual.Components
}
[BackgroundDependencyLoader]
- private void load()
+ private void load(AudioManager audio)
{
+ this.audio = audio;
+
Add(trackManager);
}
@@ -34,6 +40,7 @@ namespace osu.Game.Tests.Visual.Components
PreviewTrack track = null;
AddStep("get track", () => track = getOwnedTrack());
+ AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start", () => track.Start());
AddAssert("started", () => track.IsRunning);
AddStep("stop", () => track.Stop());
@@ -52,10 +59,15 @@ namespace osu.Game.Tests.Visual.Components
track2 = getOwnedTrack();
});
+ AddUntilStep("wait loaded", () => track1.IsLoaded && track2.IsLoaded);
+
AddStep("start track 1", () => track1.Start());
AddStep("start track 2", () => track2.Start());
AddAssert("track 1 stopped", () => !track1.IsRunning);
AddAssert("track 2 started", () => track2.IsRunning);
+ AddStep("start track 1", () => track1.Start());
+ AddAssert("track 2 stopped", () => !track2.IsRunning);
+ AddAssert("track 1 started", () => track1.IsRunning);
}
[Test]
@@ -64,6 +76,7 @@ namespace osu.Game.Tests.Visual.Components
PreviewTrack track = null;
AddStep("get track", () => track = getOwnedTrack());
+ AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start", () => track.Start());
AddStep("stop by owner", () => trackManager.StopAnyPlaying(this));
AddAssert("stopped", () => !track.IsRunning);
@@ -76,6 +89,7 @@ namespace osu.Game.Tests.Visual.Components
PreviewTrack track = null;
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
+ AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start", () => track.Start());
AddStep("attempt stop", () => trackManager.StopAnyPlaying(this));
AddAssert("not stopped", () => track.IsRunning);
@@ -83,22 +97,100 @@ namespace osu.Game.Tests.Visual.Components
AddAssert("stopped", () => !track.IsRunning);
}
- private PreviewTrack getTrack() => trackManager.Get(null);
+ [Test]
+ public void TestNonPresentTrack()
+ {
+ TestPreviewTrack track = null;
- private PreviewTrack getOwnedTrack()
+ AddStep("get non-present track", () =>
+ {
+ Add(new TestTrackOwner(track = getTrack()));
+ track.Alpha = 0;
+ });
+ AddUntilStep("wait loaded", () => track.IsLoaded);
+ AddStep("start", () => track.Start());
+ AddStep("seek to end", () => track.Track.Seek(track.Track.Length));
+ AddAssert("track stopped", () => !track.IsRunning);
+ }
+
+ ///
+ /// Ensures that changes correctly.
+ ///
+ [Test]
+ public void TestCurrentTrackChanges()
+ {
+ PreviewTrack track = null;
+ TestTrackOwner owner = null;
+
+ AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
+ AddUntilStep("wait loaded", () => track.IsLoaded);
+ AddStep("start track", () => track.Start());
+ AddAssert("current is track", () => trackManager.CurrentTrack == track);
+ AddStep("pause manager updates", () => trackManager.AllowUpdate = false);
+ AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
+ AddAssert("current not changed", () => trackManager.CurrentTrack == track);
+ AddStep("resume manager updates", () => trackManager.AllowUpdate = true);
+ AddAssert("current is null", () => trackManager.CurrentTrack == null);
+ }
+
+ ///
+ /// Ensures that mutes game-wide audio tracks correctly.
+ ///
+ [TestCase(false)]
+ [TestCase(true)]
+ public void TestEnsureMutingCorrectly(bool stopAnyPlaying)
+ {
+ PreviewTrack track = null;
+ TestTrackOwner owner = null;
+
+ AddStep("ensure volume not zero", () =>
+ {
+ if (audio.Volume.Value == 0)
+ audio.Volume.Value = 1;
+
+ if (audio.VolumeTrack.Value == 0)
+ audio.VolumeTrack.Value = 1;
+ });
+
+ AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
+
+ AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
+ AddUntilStep("wait loaded", () => track.IsLoaded);
+ AddStep("start track", () => track.Start());
+ AddAssert("game is muted", () => audio.Tracks.AggregateVolume.Value == 0);
+
+ if (stopAnyPlaying)
+ AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
+ else
+ AddStep("stop track", () => track.Stop());
+
+ AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
+ }
+
+ private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
+
+ private TestPreviewTrack getOwnedTrack()
{
var track = getTrack();
- Add(track);
+ LoadComponentAsync(track, Add);
return track;
}
private class TestTrackOwner : CompositeDrawable, IPreviewTrackOwner
{
+ private readonly PreviewTrack track;
+
public TestTrackOwner(PreviewTrack track)
{
- AddInternal(track);
+ this.track = track;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ LoadComponentAsync(track, AddInternal);
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@@ -109,14 +201,28 @@ namespace osu.Game.Tests.Visual.Components
}
}
- private class TestPreviewTrackManager : PreviewTrackManager
+ public class TestPreviewTrackManager : PreviewTrackManager
{
+ public bool AllowUpdate = true;
+
+ public new PreviewTrack CurrentTrack => base.CurrentTrack;
+
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
- protected class TestPreviewTrack : TrackManagerPreviewTrack
+ public override bool UpdateSubTree()
+ {
+ if (!AllowUpdate)
+ return true;
+
+ return base.UpdateSubTree();
+ }
+
+ public class TestPreviewTrack : TrackManagerPreviewTrack
{
private readonly ITrackStore trackManager;
+ public new Track Track => base.Track;
+
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
: base(beatmapSetInfo, trackManager)
{
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatSnapGrid.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatSnapGrid.cs
deleted file mode 100644
index 073cec7315..0000000000
--- a/osu.Game.Tests/Visual/Editor/TestSceneBeatSnapGrid.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using System;
-using NUnit.Framework;
-using osu.Framework.Allocation;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Shapes;
-using osu.Framework.MathUtils;
-using osu.Game.Beatmaps;
-using osu.Game.Beatmaps.ControlPoints;
-using osu.Game.Rulesets.Objects;
-using osu.Game.Rulesets.Osu.Beatmaps;
-using osu.Game.Rulesets.Osu.Objects;
-using osu.Game.Screens.Edit;
-using osu.Game.Screens.Edit.Compose.Components;
-using osuTK;
-using osuTK.Graphics;
-
-namespace osu.Game.Tests.Visual.Editor
-{
- public class TestSceneBeatSnapGrid : EditorClockTestScene
- {
- private const double beat_length = 100;
- private static readonly Vector2 grid_position = new Vector2(512, 384);
-
- [Cached(typeof(IEditorBeatmap))]
- private readonly EditorBeatmap editorBeatmap;
-
- private TestBeatSnapGrid grid;
-
- public TestSceneBeatSnapGrid()
- {
- editorBeatmap = new EditorBeatmap(new OsuBeatmap());
- editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
-
- createGrid();
- }
-
- [SetUp]
- public void Setup() => Schedule(() =>
- {
- Clear();
-
- editorBeatmap.ControlPointInfo.TimingPoints.Clear();
- editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
-
- BeatDivisor.Value = 1;
- });
-
- [TestCase(1)]
- [TestCase(2)]
- [TestCase(3)]
- [TestCase(4)]
- [TestCase(6)]
- [TestCase(8)]
- [TestCase(12)]
- [TestCase(16)]
- public void TestInitialBeatDivisor(int divisor)
- {
- AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
- createGrid();
-
- float expectedDistance = (float)beat_length / divisor;
- AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
- }
-
- [Test]
- public void TestChangeBeatDivisor()
- {
- createGrid();
- AddStep("set beat divisor = 2", () => BeatDivisor.Value = 2);
-
- const float expected_distance = (float)beat_length / 2;
- AddAssert($"spacing is {expected_distance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expected_distance));
- }
-
- [TestCase(100)]
- [TestCase(200)]
- public void TestBeatLength(double beatLength)
- {
- AddStep($"set beat length = {beatLength}", () =>
- {
- editorBeatmap.ControlPointInfo.TimingPoints.Clear();
- editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beatLength });
- });
-
- createGrid();
- AddAssert($"spacing is {beatLength}", () => Precision.AlmostEquals(grid.DistanceSpacing, beatLength));
- }
-
- [TestCase(1)]
- [TestCase(2)]
- public void TestGridVelocity(float velocity)
- {
- createGrid(g => g.Velocity = velocity);
-
- float expectedDistance = (float)beat_length * velocity;
- AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
- }
-
- [Test]
- public void TestGetSnappedTime()
- {
- createGrid();
-
- Vector2 snapPosition = Vector2.Zero;
- AddStep("get first tick position", () => snapPosition = grid_position + new Vector2((float)beat_length, 0));
- AddAssert("snap time is 1 beat away", () => Precision.AlmostEquals(beat_length, grid.GetSnapTime(snapPosition), 0.01));
-
- createGrid(g => g.Velocity = 2, "with velocity = 2");
- AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
- }
-
- private void createGrid(Action func = null, string description = null)
- {
- AddStep($"create grid {description ?? string.Empty}", () =>
- {
- Children = new Drawable[]
- {
- new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = Color4.SlateGray
- },
- grid = new TestBeatSnapGrid(new HitObject(), grid_position)
- };
-
- func?.Invoke(grid);
- });
- }
-
- private class TestBeatSnapGrid : BeatSnapGrid
- {
- public new float Velocity = 1;
-
- public new float DistanceSpacing => base.DistanceSpacing;
-
- public TestBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
- : base(hitObject, centrePosition)
- {
- }
-
- protected override void CreateContent(Vector2 centrePosition)
- {
- AddInternal(new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(5),
- Position = centrePosition
- });
-
- int beatIndex = 0;
-
- for (float s = centrePosition.X + DistanceSpacing; s <= DrawWidth; s += DistanceSpacing, beatIndex++)
- {
- AddInternal(new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(5, 10),
- Position = new Vector2(s, centrePosition.Y),
- Colour = GetColourForBeatIndex(beatIndex)
- });
- }
-
- beatIndex = 0;
-
- for (float s = centrePosition.X - DistanceSpacing; s >= 0; s -= DistanceSpacing, beatIndex++)
- {
- AddInternal(new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(5, 10),
- Position = new Vector2(s, centrePosition.Y),
- Colour = GetColourForBeatIndex(beatIndex)
- });
- }
-
- beatIndex = 0;
-
- for (float s = centrePosition.Y + DistanceSpacing; s <= DrawHeight; s += DistanceSpacing, beatIndex++)
- {
- AddInternal(new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(10, 5),
- Position = new Vector2(centrePosition.X, s),
- Colour = GetColourForBeatIndex(beatIndex)
- });
- }
-
- beatIndex = 0;
-
- for (float s = centrePosition.Y - DistanceSpacing; s >= 0; s -= DistanceSpacing, beatIndex++)
- {
- AddInternal(new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(10, 5),
- Position = new Vector2(centrePosition.X, s),
- Colour = GetColourForBeatIndex(beatIndex)
- });
- }
- }
-
- protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
- => Velocity;
-
- public override Vector2 GetSnapPosition(Vector2 screenSpacePosition)
- => Vector2.Zero;
- }
- }
-}
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneDistanceSnapGrid.cs b/osu.Game.Tests/Visual/Editor/TestSceneDistanceSnapGrid.cs
new file mode 100644
index 0000000000..39b4bf7218
--- /dev/null
+++ b/osu.Game.Tests/Visual/Editor/TestSceneDistanceSnapGrid.cs
@@ -0,0 +1,170 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Edit;
+using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osu.Game.Screens.Edit.Compose.Components;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Tests.Visual.Editor
+{
+ public class TestSceneDistanceSnapGrid : EditorClockTestScene
+ {
+ private const double beat_length = 100;
+ private static readonly Vector2 grid_position = new Vector2(512, 384);
+
+ [Cached(typeof(IEditorBeatmap))]
+ private readonly EditorBeatmap editorBeatmap;
+
+ [Cached(typeof(IDistanceSnapProvider))]
+ private readonly SnapProvider snapProvider = new SnapProvider();
+
+ public TestSceneDistanceSnapGrid()
+ {
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
+ }
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.SlateGray
+ },
+ new TestDistanceSnapGrid()
+ };
+ });
+
+ [TestCase(1)]
+ [TestCase(2)]
+ [TestCase(3)]
+ [TestCase(4)]
+ [TestCase(6)]
+ [TestCase(8)]
+ [TestCase(12)]
+ [TestCase(16)]
+ public void TestBeatDivisor(int divisor)
+ {
+ AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
+ }
+
+ [Test]
+ public void TestLimitedDistance()
+ {
+ AddStep("create limited grid", () =>
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.SlateGray
+ },
+ new TestDistanceSnapGrid(100)
+ };
+ });
+ }
+
+ private class TestDistanceSnapGrid : DistanceSnapGrid
+ {
+ public new float DistanceSpacing => base.DistanceSpacing;
+
+ public TestDistanceSnapGrid(double? endTime = null)
+ : base(grid_position, 0, endTime)
+ {
+ }
+
+ protected override void CreateContent(Vector2 startPosition)
+ {
+ AddInternal(new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(5),
+ Position = startPosition
+ });
+
+ int beatIndex = 0;
+
+ for (float s = startPosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
+ {
+ AddInternal(new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(5, 10),
+ Position = new Vector2(s, startPosition.Y),
+ Colour = GetColourForBeatIndex(beatIndex)
+ });
+ }
+
+ beatIndex = 0;
+
+ for (float s = startPosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
+ {
+ AddInternal(new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(5, 10),
+ Position = new Vector2(s, startPosition.Y),
+ Colour = GetColourForBeatIndex(beatIndex)
+ });
+ }
+
+ beatIndex = 0;
+
+ for (float s = startPosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
+ {
+ AddInternal(new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(10, 5),
+ Position = new Vector2(startPosition.X, s),
+ Colour = GetColourForBeatIndex(beatIndex)
+ });
+ }
+
+ beatIndex = 0;
+
+ for (float s = startPosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
+ {
+ AddInternal(new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(10, 5),
+ Position = new Vector2(startPosition.X, s),
+ Colour = GetColourForBeatIndex(beatIndex)
+ });
+ }
+ }
+
+ public override (Vector2 position, double time) GetSnappedPosition(Vector2 screenSpacePosition)
+ => (Vector2.Zero, 0);
+ }
+
+ private class SnapProvider : IDistanceSnapProvider
+ {
+ public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => (position, time);
+
+ public float GetBeatSnapDistanceAt(double referenceTime) => 10;
+
+ public float DurationToDistance(double referenceTime, double duration) => (float)duration;
+
+ public double DistanceToDuration(double referenceTime, float distance) => distance;
+
+ public double GetSnappedDurationFromDistance(double referenceTime, float distance) => 0;
+
+ public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => 0;
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs
index a8c2362910..e618256c03 100644
--- a/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs
+++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs
@@ -10,9 +10,11 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.UserInterface;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK;
using osuTK.Graphics;
@@ -25,6 +27,7 @@ namespace osu.Game.Tests.Visual.Editor
public override IReadOnlyList RequiredTypes => new[]
{
typeof(TimelineArea),
+ typeof(TimelineHitObjectDisplay),
typeof(Timeline),
typeof(TimelineButton),
typeof(CentreMarker)
@@ -35,6 +38,8 @@ namespace osu.Game.Tests.Visual.Editor
{
Beatmap.Value = new WaveformTestBeatmap(audio);
+ var editorBeatmap = new EditorBeatmap((Beatmap)Beatmap.Value.Beatmap);
+
Children = new Drawable[]
{
new FillFlowContainer
@@ -50,6 +55,7 @@ namespace osu.Game.Tests.Visual.Editor
},
new TimelineArea
{
+ Child = new TimelineHitObjectDisplay(editorBeatmap),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
@@ -101,7 +107,7 @@ namespace osu.Game.Tests.Visual.Editor
}
}
- private class StartStopButton : Button
+ private class StartStopButton : OsuButton
{
private IAdjustableClock adjustableClock;
private bool started;
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs
index b997d6aaeb..3118e0cabe 100644
--- a/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs
+++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs
@@ -28,18 +28,7 @@ namespace osu.Game.Tests.Visual.Editor
{
var testBeatmap = new Beatmap
{
- ControlPointInfo = new ControlPointInfo
- {
- TimingPoints =
- {
- new TimingControlPoint { Time = 0, BeatLength = 200 },
- new TimingControlPoint { Time = 100, BeatLength = 400 },
- new TimingControlPoint { Time = 175, BeatLength = 800 },
- new TimingControlPoint { Time = 350, BeatLength = 200 },
- new TimingControlPoint { Time = 450, BeatLength = 100 },
- new TimingControlPoint { Time = 500, BeatLength = 307.69230769230802 }
- }
- },
+ ControlPointInfo = new ControlPointInfo(),
HitObjects =
{
new HitCircle { StartTime = 0 },
@@ -47,6 +36,13 @@ namespace osu.Game.Tests.Visual.Editor
}
};
+ testBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 200 });
+ testBeatmap.ControlPointInfo.Add(100, new TimingControlPoint { BeatLength = 400 });
+ testBeatmap.ControlPointInfo.Add(175, new TimingControlPoint { BeatLength = 800 });
+ testBeatmap.ControlPointInfo.Add(350, new TimingControlPoint { BeatLength = 200 });
+ testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
+ testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
+
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs b/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs
index 0ea73fb3de..b7c7028b52 100644
--- a/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs
+++ b/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs
@@ -22,7 +22,7 @@ using osuTK;
namespace osu.Game.Tests.Visual.Editor
{
[TestFixture]
- public class TestSceneHitObjectComposer : OsuTestScene
+ public class TestSceneHitObjectComposer : EditorClockTestScene
{
public override IReadOnlyList RequiredTypes => new[]
{
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs b/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
new file mode 100644
index 0000000000..121853d8d0
--- /dev/null
+++ b/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
@@ -0,0 +1,35 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Edit.Timing;
+
+namespace osu.Game.Tests.Visual.Editor
+{
+ [TestFixture]
+ public class TestSceneTimingScreen : EditorClockTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(ControlPointTable),
+ typeof(ControlPointSettings),
+ typeof(Section<>),
+ typeof(TimingSection),
+ typeof(EffectSection),
+ typeof(SampleSection),
+ typeof(DifficultySection),
+ typeof(RowAttribute)
+ };
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
+ Child = new TimingScreen();
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs
index f94071a7a9..5ee109e3dd 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs
@@ -7,6 +7,7 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
+using osu.Game.Storyboards;
namespace osu.Game.Tests.Visual.Gameplay
{
@@ -29,9 +30,9 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("key counter reset", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0));
}
- protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
{
- var working = base.CreateWorkingBeatmap(beatmap);
+ var working = base.CreateWorkingBeatmap(beatmap, storyboard);
track = (ClockBackedTestWorkingBeatmap.TrackVirtualManual)working.Track;
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs
index a934d22b5d..e3688c276f 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs
@@ -9,7 +9,7 @@ using osu.Game.Rulesets.Judgements;
using osu.Framework.MathUtils;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Catch.Scoring;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Osu.Scoring;
@@ -85,9 +85,9 @@ namespace osu.Game.Tests.Visual.Gameplay
AutoSizeAxes = Axes.Both,
Children = new[]
{
- new SpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" },
- new SpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" },
- new SpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" },
+ new OsuSpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" },
+ new OsuSpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" },
+ new OsuSpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" },
}
});
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBreakOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBreakOverlay.cs
index 879e15c548..19dce303ea 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneBreakOverlay.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBreakOverlay.cs
@@ -95,6 +95,19 @@ namespace osu.Game.Tests.Visual.Gameplay
seekAndAssertBreak("seek to break after end", testBreaks[1].EndTime + 500, false);
}
+ [TestCase(true)]
+ [TestCase(false)]
+ public void TestBeforeGameplayStart(bool withBreaks)
+ {
+ setClock(true);
+
+ if (withBreaks)
+ loadBreaksStep("multiple breaks", testBreaks);
+
+ seekAndAssertBreak("seek to break intro time", -100, true);
+ seekAndAssertBreak("seek to break intro time", 0, false);
+ }
+
private void addShowBreakStep(double seconds)
{
AddStep($"show '{seconds}s' break", () => breakOverlay.Breaks = new List
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableScrollingRuleset.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableScrollingRuleset.cs
index dcab964d6d..684e79b3f5 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableScrollingRuleset.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableScrollingRuleset.cs
@@ -47,7 +47,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestRelativeBeatLengthScaleSingleTimingPoint()
{
- var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range / 2 });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
@@ -61,10 +62,10 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestRelativeBeatLengthScaleTimingPointBeyondEndDoesNotBecomeDominant()
{
- var beatmap = createBeatmap(
- new TimingControlPoint { BeatLength = time_range / 2 },
- new TimingControlPoint { Time = 12000, BeatLength = time_range },
- new TimingControlPoint { Time = 100000, BeatLength = time_range });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
+ beatmap.ControlPointInfo.Add(12000, new TimingControlPoint { BeatLength = time_range });
+ beatmap.ControlPointInfo.Add(100000, new TimingControlPoint { BeatLength = time_range });
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
@@ -75,9 +76,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestRelativeBeatLengthScaleFromSecondTimingPoint()
{
- var beatmap = createBeatmap(
- new TimingControlPoint { BeatLength = time_range },
- new TimingControlPoint { Time = 3 * time_range, BeatLength = time_range / 2 });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
+ beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
@@ -97,9 +98,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestNonRelativeScale()
{
- var beatmap = createBeatmap(
- new TimingControlPoint { BeatLength = time_range },
- new TimingControlPoint { Time = 3 * time_range, BeatLength = time_range / 2 });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
+ beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
createTest(beatmap);
@@ -119,7 +120,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestSliderMultiplierDoesNotAffectRelativeBeatLength()
{
- var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
@@ -132,7 +134,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestSliderMultiplierAffectsNonRelativeBeatLength()
{
- var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
+ var beatmap = createBeatmap();
+ beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
createTest(beatmap);
@@ -154,14 +157,11 @@ namespace osu.Game.Tests.Visual.Gameplay
/// Creates an , containing 10 hitobjects and user-provided timing points.
/// The hitobjects are spaced milliseconds apart.
///
- /// The timing points to add to the beatmap.
/// The .
- private IBeatmap createBeatmap(params TimingControlPoint[] timingControlPoints)
+ private IBeatmap createBeatmap()
{
var beatmap = new Beatmap { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } };
- beatmap.ControlPointInfo.TimingPoints.AddRange(timingControlPoints);
-
for (int i = 0; i < 10; i++)
beatmap.HitObjects.Add(new HitObject { StartTime = i * time_range });
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs
index ffc025a942..b2b58a63fb 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs
@@ -17,6 +17,7 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
+using osu.Game.Storyboards;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
@@ -35,9 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private Track track;
- protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
{
- var working = new ClockBackedTestWorkingBeatmap(beatmap, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
+ var working = new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
track = working.Track;
return working;
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs
new file mode 100644
index 0000000000..0150c6ea74
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs
@@ -0,0 +1,113 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Diagnostics;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.MathUtils;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Play;
+using osu.Game.Storyboards;
+using osu.Game.Tests.Beatmaps;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
+ {
+ private LeadInPlayer player;
+
+ private const double lenience_ms = 10;
+
+ private const double first_hit_object = 2170;
+
+ [TestCase(1000, 0)]
+ [TestCase(2000, 0)]
+ [TestCase(3000, first_hit_object - 3000)]
+ [TestCase(10000, first_hit_object - 10000)]
+ public void TestLeadInProducesCorrectStartTime(double leadIn, double expectedStartTime)
+ {
+ loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
+ {
+ BeatmapInfo = { AudioLeadIn = leadIn }
+ });
+
+ AddAssert($"first frame is {expectedStartTime}", () =>
+ {
+ Debug.Assert(player.FirstFrameClockTime != null);
+ return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms);
+ });
+ }
+
+ [TestCase(1000, 0)]
+ [TestCase(0, 0)]
+ [TestCase(-1000, -1000)]
+ [TestCase(-10000, -10000)]
+ public void TestStoryboardProducesCorrectStartTime(double firstStoryboardEvent, double expectedStartTime)
+ {
+ var storyboard = new Storyboard();
+
+ var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
+ sprite.TimelineGroup.Alpha.Add(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1);
+
+ storyboard.GetLayer("Background").Add(sprite);
+
+ loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), storyboard);
+
+ AddAssert($"first frame is {expectedStartTime}", () =>
+ {
+ Debug.Assert(player.FirstFrameClockTime != null);
+ return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms);
+ });
+ }
+
+ private void loadPlayerWithBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
+ {
+ AddStep("create player", () =>
+ {
+ Beatmap.Value = CreateWorkingBeatmap(beatmap, storyboard);
+ LoadScreen(player = new LeadInPlayer());
+ });
+
+ AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
+ }
+
+ private class LeadInPlayer : TestPlayer
+ {
+ public LeadInPlayer()
+ : base(false, false)
+ {
+ }
+
+ public double? FirstFrameClockTime;
+
+ public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
+
+ public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
+
+ public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime;
+
+ public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
+
+ protected override void UpdateAfterChildren()
+ {
+ base.UpdateAfterChildren();
+
+ if (!FirstFrameClockTime.HasValue)
+ {
+ FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
+ AddInternal(new OsuSpriteText
+ {
+ Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
+ + $"FirstHitObjectTime: {FirstHitObjectTime} "
+ + $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
+ + $"FirstFrameClockTime: {FirstFrameClockTime}"
+ });
+ }
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs
index 2df22df659..e04315894e 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs
@@ -69,6 +69,24 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(true);
}
+ [Test]
+ public void TestPauseWithResumeOverlay()
+ {
+ AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
+ AddUntilStep("wait for hitobjects", () => Player.ScoreProcessor.Health.Value < 1);
+
+ pauseAndConfirm();
+
+ resume();
+ confirmClockRunning(false);
+ confirmPauseOverlayShown(false);
+
+ pauseAndConfirm();
+
+ AddUntilStep("resume overlay is not active", () => Player.DrawableRuleset.ResumeOverlay.State.Value == Visibility.Hidden);
+ confirmPaused();
+ }
+
[Test]
public void TestResumeWithResumeOverlaySkipped()
{
@@ -97,8 +115,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestExitTooSoon()
{
- pauseAndConfirm();
+ AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
+ pauseAndConfirm();
resume();
AddStep("exit too soon", () => Player.Exit());
@@ -158,7 +177,9 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestExitFromGameplay()
{
AddStep("exit", () => Player.Exit());
+ confirmPaused();
+ AddStep("exit", () => Player.Exit());
confirmExited();
}
@@ -196,6 +217,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestRestartAfterResume()
{
+ AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
+
pauseAndConfirm();
resumeAndConfirm();
restart();
@@ -219,6 +242,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("player not exited", () => Player.IsCurrentScreen());
AddStep("exit", () => Player.Exit());
confirmExited();
+ confirmNoTrackAdjustments();
}
private void confirmPaused()
@@ -240,6 +264,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("player exited", () => !Player.IsCurrentScreen());
}
+ private void confirmNoTrackAdjustments()
+ {
+ AddAssert("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value == 1);
+ }
+
private void restart() => AddStep("restart", () => Player.Restart());
private void pause() => AddStep("pause", () => Player.Pause());
private void resume() => AddStep("resume", () => Player.Resume());
@@ -256,8 +285,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected class PausePlayer : TestPlayer
{
- public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
-
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public new HUDOverlay HUDOverlay => base.HUDOverlay;
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
new file mode 100644
index 0000000000..3513b6c25a
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
@@ -0,0 +1,51 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Platform;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Play;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ [HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
+ public class TestScenePauseWhenInactive : PlayerTestScene
+ {
+ protected new TestPlayer Player => (TestPlayer)base.Player;
+
+ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
+ {
+ var beatmap = (Beatmap)base.CreateBeatmap(ruleset);
+
+ beatmap.HitObjects.RemoveAll(h => h.StartTime < 30000);
+
+ return beatmap;
+ }
+
+ [Resolved]
+ private GameHost host { get; set; }
+
+ public TestScenePauseWhenInactive()
+ : base(new OsuRuleset())
+ {
+ }
+
+ [Test]
+ public void TestDoesntPauseDuringIntro()
+ {
+ AddStep("set inactive", () => ((Bindable)host.IsActive).Value = false);
+
+ AddStep("resume player", () => Player.GameplayClockContainer.Start());
+ AddAssert("ensure not paused", () => !Player.GameplayClockContainer.IsPaused.Value);
+ AddUntilStep("wait for pause", () => Player.GameplayClockContainer.IsPaused.Value);
+ AddAssert("time of pause is after gameplay start time", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= Player.DrawableRuleset.GameplayStartTime);
+ }
+
+ protected override Player CreatePlayer(Ruleset ruleset) => new TestPlayer(true, true, true);
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
index 74ae641bfe..f02361e685 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@@ -19,6 +20,7 @@ using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens;
@@ -55,6 +57,9 @@ namespace osu.Game.Tests.Visual.Gameplay
beforeLoadAction?.Invoke();
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
+ foreach (var mod in Mods.Value.OfType())
+ mod.ApplyToTrack(Beatmap.Value.Track);
+
InputManager.Child = container = new TestPlayerLoaderContainer(
loader = new TestPlayerLoader(() =>
{
@@ -63,6 +68,24 @@ namespace osu.Game.Tests.Visual.Gameplay
}));
}
+ ///
+ /// When exits early, it has to wait for the player load task
+ /// to complete before running disposal on player. This previously caused an issue where mod
+ /// speed adjustments were undone too late, causing cross-screen pollution.
+ ///
+ [Test]
+ public void TestEarlyExit()
+ {
+ AddStep("load dummy beatmap", () => ResetPlayer(false, () => Mods.Value = new[] { new OsuModNightcore() }));
+ AddUntilStep("wait for current", () => loader.IsCurrentScreen());
+ AddAssert("mod rate applied", () => Beatmap.Value.Track.Rate != 1);
+ AddStep("exit loader", () => loader.Exit());
+ AddUntilStep("wait for not current", () => !loader.IsCurrentScreen());
+ AddAssert("player did not load", () => !player.IsLoaded);
+ AddUntilStep("player disposed", () => loader.DisposalTask?.IsCompleted == true);
+ AddAssert("mod rate still applied", () => Beatmap.Value.Track.Rate != 1);
+ }
+
[Test]
public void TestBlockLoadViaMouseMovement()
{
@@ -196,6 +219,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
public new VisualSettings VisualSettings => base.VisualSettings;
+ public new Task DisposalTask => base.DisposalTask;
+
public TestPlayerLoader(Func createPlayer)
: base(createPlayer)
{
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs
index 65b56319e8..4d701f56a9 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs
@@ -6,6 +6,7 @@ using osu.Framework.Lists;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Screens.Play;
+using osu.Game.Storyboards;
namespace osu.Game.Tests.Visual.Gameplay
{
@@ -42,9 +43,9 @@ namespace osu.Game.Tests.Visual.Gameplay
});
}
- protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
{
- var working = base.CreateWorkingBeatmap(beatmap);
+ var working = base.CreateWorkingBeatmap(beatmap, storyboard);
workingWeakReferences.Add(working);
return working;
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
index 0dfcda122f..8cb44de8cb 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs
@@ -5,19 +5,22 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
-using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
-using osu.Game.Screens.Play;
using osu.Game.Users;
-using osuTK;
using System;
using System.Collections.Generic;
+using osu.Framework.Allocation;
+using osu.Game.Rulesets;
+using osu.Game.Screens.Ranking.Pages;
namespace osu.Game.Tests.Visual.Gameplay
{
[TestFixture]
public class TestSceneReplayDownloadButton : OsuTestScene
{
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
+
public override IReadOnlyList RequiredTypes => new[]
{
typeof(ReplayDownloadButton)
@@ -42,7 +45,6 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- Size = new Vector2(80, 40),
};
});
}
@@ -51,16 +53,15 @@ namespace osu.Game.Tests.Visual.Gameplay
{
return new APILegacyScoreInfo
{
- ID = 1,
OnlineScoreID = 2553163309,
- Ruleset = new OsuRuleset().RulesetInfo,
+ OnlineRulesetID = 0,
Replay = replayAvailable,
User = new User
{
Id = 39828,
Username = @"WubWoofWolf",
}
- };
+ }.CreateScoreInfo(rulesets);
}
private class TestReplayDownloadButton : ReplayDownloadButton
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplaySettingsOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplaySettingsOverlay.cs
index 944480243d..cdfb3beb19 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplaySettingsOverlay.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplaySettingsOverlay.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.PlayerSettings;
@@ -20,6 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
+ State = { Value = Visibility.Visible }
});
Add(container = new ExampleContainer());
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs
index f3c8f89db7..7790126db5 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneResults.cs
@@ -3,11 +3,16 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
+using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Ranking.Pages;
@@ -22,11 +27,13 @@ namespace osu.Game.Tests.Visual.Gameplay
public override IReadOnlyList RequiredTypes => new[]
{
- typeof(ScoreInfo),
typeof(Results),
typeof(ResultsPage),
typeof(ScoreResultsPage),
- typeof(LocalLeaderboardPage)
+ typeof(RetryButton),
+ typeof(ReplayDownloadButton),
+ typeof(LocalLeaderboardPage),
+ typeof(TestPlayer)
};
[BackgroundDependencyLoader]
@@ -42,26 +49,82 @@ namespace osu.Game.Tests.Visual.Gameplay
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
+ }
- LoadScreen(new SoloResults(new ScoreInfo
+ private TestSoloResults createResultsScreen() => new TestSoloResults(new ScoreInfo
+ {
+ TotalScore = 2845370,
+ Accuracy = 0.98,
+ MaxCombo = 123,
+ Rank = ScoreRank.A,
+ Date = DateTimeOffset.Now,
+ Statistics = new Dictionary
{
- TotalScore = 2845370,
- Accuracy = 0.98,
- MaxCombo = 123,
- Rank = ScoreRank.A,
- Date = DateTimeOffset.Now,
- Statistics = new Dictionary
+ { HitResult.Great, 50 },
+ { HitResult.Good, 20 },
+ { HitResult.Meh, 50 },
+ { HitResult.Miss, 1 }
+ },
+ User = new User
+ {
+ Username = "peppy",
+ }
+ });
+
+ [Test]
+ public void ResultsWithoutPlayer()
+ {
+ TestSoloResults screen = null;
+
+ AddStep("load results", () => Child = new OsuScreenStack(screen = createResultsScreen())
+ {
+ RelativeSizeAxes = Axes.Both
+ });
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
+ }
+
+ [Test]
+ public void ResultsWithPlayer()
+ {
+ TestSoloResults screen = null;
+
+ AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddAssert("retry overlay present", () => screen.RetryOverlay != null);
+ }
+
+ private class TestResultsContainer : Container
+ {
+ [Cached(typeof(Player))]
+ private readonly Player player = new TestPlayer();
+
+ public TestResultsContainer(IScreen screen)
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChild = new OsuScreenStack(screen)
{
- { HitResult.Great, 50 },
- { HitResult.Good, 20 },
- { HitResult.Meh, 50 },
- { HitResult.Miss, 1 }
- },
- User = new User
- {
- Username = "peppy",
- }
- }));
+ RelativeSizeAxes = Axes.Both,
+ };
+ }
+ }
+
+ private class TestSoloResults : SoloResults
+ {
+ public HotkeyRetryOverlay RetryOverlay;
+
+ public TestSoloResults(ScoreInfo score)
+ : base(score)
+ {
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ RetryOverlay = InternalChildren.OfType().SingleOrDefault();
+ }
}
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs
index b3d4820737..ec94053679 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs
@@ -326,21 +326,23 @@ namespace osu.Game.Tests.Visual.Gameplay
public IBindable GetConfig(TLookup lookup) => throw new NotImplementedException();
- public event Action SourceChanged;
+ public event Action SourceChanged
+ {
+ add { }
+ remove { }
+ }
}
private class TestSkinComponent : ISkinComponent
{
- private readonly string name;
-
public TestSkinComponent(string name)
{
- this.name = name;
+ LookupName = name;
}
public string ComponentGroup => string.Empty;
- public string LookupName => name;
+ public string LookupName { get; }
}
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs
index b152c21454..875e7b9758 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs
@@ -4,8 +4,8 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Timing;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osuTK;
using osuTK.Input;
@@ -18,25 +18,37 @@ namespace osu.Game.Tests.Visual.Gameplay
private SkipOverlay skip;
private int requestCount;
+ private double increment;
+
+ private GameplayClockContainer gameplayClockContainer;
+ private GameplayClock gameplayClock;
+
+ private const double skip_time = 6000;
+
[SetUp]
public void SetUp() => Schedule(() =>
{
requestCount = 0;
- Child = new Container
+ increment = skip_time;
+
+ Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new Mod[] { }, 0)
{
RelativeSizeAxes = Axes.Both,
- Clock = new FramedOffsetClock(Clock)
- {
- Offset = -Clock.CurrentTime,
- },
Children = new Drawable[]
{
- skip = new SkipOverlay(6000)
+ skip = new SkipOverlay(skip_time)
{
- RequestSeek = _ => requestCount++
+ RequestSkip = () =>
+ {
+ requestCount++;
+ gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
+ }
}
},
};
+
+ gameplayClockContainer.Start();
+ gameplayClock = gameplayClockContainer.GameplayClock;
});
[Test]
@@ -64,19 +76,35 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestClickOnlyActuatesOnce()
{
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
- AddStep("click", () => InputManager.Click(MouseButton.Left));
+ AddStep("click", () =>
+ {
+ increment = skip_time - gameplayClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2;
+ InputManager.Click(MouseButton.Left);
+ });
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkRequestCount(1);
}
+ [Test]
+ public void TestClickOnlyActuatesMultipleTimes()
+ {
+ AddStep("set increment lower", () => increment = 3000);
+ AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+ checkRequestCount(2);
+ }
+
[Test]
public void TestDoesntFadeOnMouseDown()
{
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
- AddUntilStep("wait for overlay disapper", () => !skip.IsAlive);
+ AddUntilStep("wait for overlay disappear", () => !skip.IsPresent);
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0);
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
checkRequestCount(0);
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSliderPath.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSliderPath.cs
new file mode 100644
index 0000000000..606395c289
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSliderPath.cs
@@ -0,0 +1,193 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Lines;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Types;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneSliderPath : OsuTestScene
+ {
+ private readonly SmoothPath drawablePath;
+ private SliderPath path;
+
+ public TestSceneSliderPath()
+ {
+ Child = drawablePath = new SmoothPath
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre
+ };
+ }
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ path = new SliderPath();
+ });
+
+ protected override void Update()
+ {
+ base.Update();
+
+ if (path != null)
+ {
+ List vertices = new List();
+ path.GetPathToProgress(vertices, 0, 1);
+
+ drawablePath.Vertices = vertices;
+ }
+ }
+
+ [Test]
+ public void TestEmptyPath()
+ {
+ }
+
+ [TestCase(PathType.Linear)]
+ [TestCase(PathType.Bezier)]
+ [TestCase(PathType.Catmull)]
+ [TestCase(PathType.PerfectCurve)]
+ public void TestSingleSegment(PathType type)
+ => AddStep("create path", () => path.ControlPoints.AddRange(createSegment(type, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+
+ [TestCase(PathType.Linear)]
+ [TestCase(PathType.Bezier)]
+ [TestCase(PathType.Catmull)]
+ [TestCase(PathType.PerfectCurve)]
+ public void TestMultipleSegment(PathType type)
+ {
+ AddStep("create path", () =>
+ {
+ path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero));
+ path.ControlPoints.AddRange(createSegment(type, new Vector2(0, 100), new Vector2(100), Vector2.Zero));
+ });
+ }
+
+ [Test]
+ public void TestAddControlPoint()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100))));
+ AddStep("add point", () => path.ControlPoints.Add(new PathControlPoint { Position = { Value = new Vector2(100) } }));
+ }
+
+ [Test]
+ public void TestInsertControlPoint()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(100))));
+ AddStep("insert point", () => path.ControlPoints.Insert(1, new PathControlPoint { Position = { Value = new Vector2(0, 100) } }));
+ }
+
+ [Test]
+ public void TestRemoveControlPoint()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("remove second point", () => path.ControlPoints.RemoveAt(1));
+ }
+
+ [Test]
+ public void TestChangePathType()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("change type to bezier", () => path.ControlPoints[0].Type.Value = PathType.Bezier);
+ }
+
+ [Test]
+ public void TestAddSegmentByChangingType()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0))));
+ AddStep("change second point type to bezier", () => path.ControlPoints[1].Type.Value = PathType.Bezier);
+ }
+
+ [Test]
+ public void TestRemoveSegmentByChangingType()
+ {
+ AddStep("create path", () =>
+ {
+ path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
+ path.ControlPoints[1].Type.Value = PathType.Bezier;
+ });
+
+ AddStep("change second point type to null", () => path.ControlPoints[1].Type.Value = null);
+ }
+
+ [Test]
+ public void TestRemoveSegmentByRemovingControlPoint()
+ {
+ AddStep("create path", () =>
+ {
+ path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
+ path.ControlPoints[1].Type.Value = PathType.Bezier;
+ });
+
+ AddStep("remove second point", () => path.ControlPoints.RemoveAt(1));
+ }
+
+ [TestCase(2)]
+ [TestCase(4)]
+ public void TestPerfectCurveFallbackScenarios(int points)
+ {
+ AddStep("create path", () =>
+ {
+ switch (points)
+ {
+ case 2:
+ path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100)));
+ break;
+
+ case 4:
+ path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
+ break;
+ }
+ });
+ }
+
+ [Test]
+ public void TestLengthenLastSegment()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("lengthen last segment", () => path.ExpectedDistance.Value = 300);
+ }
+
+ [Test]
+ public void TestShortenLastSegment()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("shorten last segment", () => path.ExpectedDistance.Value = 150);
+ }
+
+ [Test]
+ public void TestShortenFirstSegment()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("shorten first segment", () => path.ExpectedDistance.Value = 50);
+ }
+
+ [Test]
+ public void TestShortenToZeroLength()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("shorten to 0 length", () => path.ExpectedDistance.Value = 0);
+ }
+
+ [Test]
+ public void TestShortenToNegativeLength()
+ {
+ AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
+ AddStep("shorten to -10 length", () => path.ExpectedDistance.Value = -10);
+ }
+
+ private List createSegment(PathType type, params Vector2[] controlPoints)
+ {
+ var points = controlPoints.Select(p => new PathControlPoint { Position = { Value = p } }).ToList();
+ points[0].Type.Value = type;
+ return points;
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoaderAnimation.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoaderAnimation.cs
index 000832b784..61fed3013e 100644
--- a/osu.Game.Tests/Visual/Menus/TestSceneLoaderAnimation.cs
+++ b/osu.Game.Tests/Visual/Menus/TestSceneLoaderAnimation.cs
@@ -33,23 +33,15 @@ namespace osu.Game.Tests.Visual.Menus
[Test]
public void TestInstantLoad()
{
- bool logoVisible = false;
+ // visual only, very impossible to test this using asserts.
- AddStep("begin loading", () =>
+ AddStep("load immediately", () =>
{
loader = new TestLoader();
loader.AllowLoad.Set();
LoadScreen(loader);
});
-
- AddUntilStep("loaded", () =>
- {
- logoVisible = loader.Logo?.Alpha > 0;
- return loader.Logo != null && loader.ScreenLoaded;
- });
-
- AddAssert("logo was not visible", () => !logoVisible);
}
[Test]
@@ -58,7 +50,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
AddStep("finish loading", () => loader.AllowLoad.Set());
- AddAssert("loaded", () => loader.Logo != null && loader.ScreenLoaded);
+ AddUntilStep("loaded", () => loader.Logo != null && loader.ScreenLoaded);
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
}
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchResults.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchResults.cs
index 7915a981dd..58e9240026 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchResults.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchResults.cs
@@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private class TestMatchLeaderboard : RoomLeaderboardPage.ResultsMatchLeaderboard
{
- protected override APIRequest FetchScores(Action> scoresCallback)
+ protected override APIRequest FetchScores(Action> scoresCallback)
{
var scores = Enumerable.Range(0, 50).Select(createRoomScore).ToArray();
@@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
return null;
}
- private APIRoomScoreInfo createRoomScore(int id) => new APIRoomScoreInfo
+ private APIUserScoreAggregate createRoomScore(int id) => new APIUserScoreAggregate
{
User = new User { Id = id, Username = $"User {id}" },
Accuracy = 0.98,
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
new file mode 100644
index 0000000000..1f8df438fb
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
@@ -0,0 +1,102 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.UserInterface;
+using osu.Game.Beatmaps;
+using osu.Game.Overlays.BeatmapSet;
+using osu.Game.Rulesets;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneBeatmapRulesetSelector : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(BeatmapRulesetSelector),
+ typeof(BeatmapRulesetTabItem),
+ };
+
+ private readonly TestRulesetSelector selector;
+
+ public TestSceneBeatmapRulesetSelector()
+ {
+ Add(selector = new TestRulesetSelector());
+ }
+
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
+
+ [Test]
+ public void TestMultipleRulesetsBeatmapSet()
+ {
+ var enabledRulesets = rulesets.AvailableRulesets.Skip(1).Take(2);
+
+ AddStep("load multiple rulesets beatmapset", () =>
+ {
+ selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = enabledRulesets.Select(r => new BeatmapInfo { Ruleset = r }).ToList()
+ };
+ });
+
+ var tabItems = selector.TabContainer.TabItems;
+ AddAssert("other rulesets disabled", () => tabItems.Except(tabItems.Where(t => enabledRulesets.Any(r => r.Equals(t.Value)))).All(t => !t.Enabled.Value));
+ AddAssert("left-most ruleset selected", () => tabItems.First(t => t.Enabled.Value).Active.Value);
+ }
+
+ [Test]
+ public void TestSingleRulesetBeatmapSet()
+ {
+ var enabledRuleset = rulesets.AvailableRulesets.Last();
+
+ AddStep("load single ruleset beatmapset", () =>
+ {
+ selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = new List
+ {
+ new BeatmapInfo
+ {
+ Ruleset = enabledRuleset
+ }
+ }
+ };
+ });
+
+ AddAssert("single ruleset selected", () => selector.SelectedTab.Value.Equals(enabledRuleset));
+ }
+
+ [Test]
+ public void TestEmptyBeatmapSet()
+ {
+ AddStep("load empty beatmapset", () => selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = new List()
+ });
+
+ AddAssert("no ruleset selected", () => selector.SelectedTab == null);
+ AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
+ }
+
+ [Test]
+ public void TestNullBeatmapSet()
+ {
+ AddStep("load null beatmapset", () => selector.BeatmapSet = null);
+
+ AddAssert("no ruleset selected", () => selector.SelectedTab == null);
+ AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
+ }
+
+ private class TestRulesetSelector : BeatmapRulesetSelector
+ {
+ public new TabItem SelectedTab => base.SelectedTab;
+
+ public new TabFillFlowContainer TabContainer => base.TabContainer;
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
index 9f03d947b9..5ca2c9868f 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
@@ -40,24 +40,20 @@ namespace osu.Game.Tests.Visual.Online
typeof(PreviewButton),
typeof(SuccessRate),
typeof(BeatmapAvailability),
+ typeof(BeatmapRulesetSelector),
+ typeof(BeatmapRulesetTabItem),
+ typeof(NotSupporterPlaceholder)
};
protected override bool UseOnlineAPI => true;
- private RulesetInfo taikoRuleset;
- private RulesetInfo maniaRuleset;
-
public TestSceneBeatmapSetOverlay()
{
Add(overlay = new TestBeatmapSetOverlay());
}
- [BackgroundDependencyLoader]
- private void load(RulesetStore rulesets)
- {
- taikoRuleset = rulesets.GetRuleset(1);
- maniaRuleset = rulesets.GetRuleset(3);
- }
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
[Test]
public void TestLoading()
@@ -111,7 +107,7 @@ namespace osu.Game.Tests.Visual.Online
StarDifficulty = 9.99,
Version = @"TEST",
Length = 456000,
- Ruleset = maniaRuleset,
+ Ruleset = rulesets.GetRuleset(3),
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 1,
@@ -189,7 +185,7 @@ namespace osu.Game.Tests.Visual.Online
StarDifficulty = 5.67,
Version = @"ANOTHER TEST",
Length = 123000,
- Ruleset = taikoRuleset,
+ Ruleset = rulesets.GetRuleset(1),
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 9,
@@ -217,6 +213,54 @@ namespace osu.Game.Tests.Visual.Online
downloadAssert(false);
}
+ [Test]
+ public void TestMultipleRulesets()
+ {
+ AddStep("show multiple rulesets beatmap", () =>
+ {
+ var beatmaps = new List();
+
+ foreach (var ruleset in rulesets.AvailableRulesets.Skip(1))
+ {
+ beatmaps.Add(new BeatmapInfo
+ {
+ Version = ruleset.Name,
+ Ruleset = ruleset,
+ BaseDifficulty = new BeatmapDifficulty(),
+ OnlineInfo = new BeatmapOnlineInfo(),
+ Metrics = new BeatmapMetrics
+ {
+ Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
+ Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
+ },
+ });
+ }
+
+ overlay.ShowBeatmapSet(new BeatmapSetInfo
+ {
+ Metadata = new BeatmapMetadata
+ {
+ Title = @"multiple rulesets beatmap",
+ Artist = @"none",
+ Author = new User
+ {
+ Username = "BanchoBot",
+ Id = 3,
+ }
+ },
+ OnlineInfo = new BeatmapSetOnlineInfo
+ {
+ Covers = new BeatmapSetOnlineCovers(),
+ },
+ Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
+ Beatmaps = beatmaps
+ });
+ });
+
+ AddAssert("shown beatmaps of current ruleset", () => overlay.Header.Picker.Difficulties.All(b => b.Beatmap.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value)));
+ AddAssert("left-most beatmap selected", () => overlay.Header.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
+ }
+
[Test]
public void TestHide()
{
@@ -281,12 +325,12 @@ namespace osu.Game.Tests.Visual.Online
private void downloadAssert(bool shown)
{
- AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown);
+ AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsVisible == shown);
}
private class TestBeatmapSetOverlay : BeatmapSetOverlay
{
- public bool DownloadButtonsVisible => Header.DownloadButtonsVisible;
+ public new Header Header => base.Header;
}
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs
index 05f5c117e4..80fad44593 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs
@@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("set second set", () => successRate.Beatmap = secondBeatmap);
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics);
- BeatmapInfo createBeatmap() => new BeatmapInfo
+ static BeatmapInfo createBeatmap() => new BeatmapInfo
{
Metrics = new BeatmapMetrics
{
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
new file mode 100644
index 0000000000..86bd0ddd11
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -0,0 +1,59 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Game.Online.API.Requests;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Game.Overlays.Comments;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ [TestFixture]
+ public class TestSceneCommentsContainer : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(CommentsContainer),
+ typeof(CommentsHeader),
+ typeof(DrawableComment),
+ typeof(HeaderButton),
+ typeof(SortTabControl),
+ typeof(ShowChildrenButton),
+ typeof(DeletedChildrenPlaceholder),
+ typeof(VotePill)
+ };
+
+ protected override bool UseOnlineAPI => true;
+
+ public TestSceneCommentsContainer()
+ {
+ BasicScrollContainer scrollFlow;
+
+ Add(scrollFlow = new BasicScrollContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ });
+
+ AddStep("Big Black comments", () =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
+ });
+
+ AddStep("Airman comments", () =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313));
+ });
+
+ AddStep("lazer build comments", () =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Build, 4772));
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
new file mode 100644
index 0000000000..bc3e0eff1a
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
@@ -0,0 +1,39 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Bindables;
+using osu.Game.Overlays.Comments;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ [TestFixture]
+ public class TestSceneCommentsHeader : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(CommentsHeader),
+ typeof(HeaderButton),
+ typeof(SortTabControl),
+ };
+
+ private readonly Bindable sort = new Bindable();
+ private readonly BindableBool showDeleted = new BindableBool();
+
+ public TestSceneCommentsHeader()
+ {
+ Add(new CommentsHeader
+ {
+ Sort = { BindTarget = sort },
+ ShowDeleted = { BindTarget = showDeleted }
+ });
+
+ AddStep("Trigger ShowDeleted", () => showDeleted.Value = !showDeleted.Value);
+ AddStep("Select old", () => sort.Value = CommentsSortCriteria.Old);
+ AddStep("Select new", () => sort.Value = CommentsSortCriteria.New);
+ AddStep("Select top", () => sort.Value = CommentsSortCriteria.Top);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs b/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs
new file mode 100644
index 0000000000..8e2ee4e28d
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs
@@ -0,0 +1,54 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Overlays.BeatmapSet.Buttons;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneFavouriteButton : OsuTestScene
+ {
+ private FavouriteButton favourite;
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("create button", () => Child = favourite = new FavouriteButton
+ {
+ RelativeSizeAxes = Axes.None,
+ Size = new Vector2(50),
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ });
+ }
+
+ [Test]
+ public void TestLoggedOutIn()
+ {
+ AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 });
+ AddStep("log out", () => API.Logout());
+ checkEnabled(false);
+ AddStep("log in", () => API.Login("test", "test"));
+ checkEnabled(true);
+ }
+
+ [Test]
+ public void TestBeatmapChange()
+ {
+ AddStep("log in", () => API.Login("test", "test"));
+ AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 });
+ checkEnabled(true);
+ AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo());
+ checkEnabled(false);
+ }
+
+ private void checkEnabled(bool expected)
+ {
+ AddAssert("is " + (expected ? "enabled" : "disabled"), () => favourite.Enabled.Value == expected);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
new file mode 100644
index 0000000000..e0e5a088ce
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
@@ -0,0 +1,78 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Overlays.BeatmapSet;
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Mania;
+using osu.Game.Rulesets.Taiko;
+using osu.Game.Rulesets.Catch;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Extensions.IEnumerableExtensions;
+using osu.Framework.Bindables;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneLeaderboardModSelector : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(LeaderboardModSelector),
+ };
+
+ public TestSceneLeaderboardModSelector()
+ {
+ LeaderboardModSelector modSelector;
+ FillFlowContainer selectedMods;
+ var ruleset = new Bindable();
+
+ Add(selectedMods = new FillFlowContainer
+ {
+ Anchor = Anchor.TopLeft,
+ Origin = Anchor.TopLeft,
+ });
+
+ Add(modSelector = new LeaderboardModSelector
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Ruleset = { BindTarget = ruleset }
+ });
+
+ modSelector.SelectedMods.ItemsAdded += mods =>
+ {
+ mods.ForEach(mod => selectedMods.Add(new OsuSpriteText
+ {
+ Text = mod.Acronym,
+ }));
+ };
+
+ modSelector.SelectedMods.ItemsRemoved += mods =>
+ {
+ mods.ForEach(mod =>
+ {
+ foreach (var selected in selectedMods)
+ {
+ if (selected.Text == mod.Acronym)
+ {
+ selectedMods.Remove(selected);
+ break;
+ }
+ }
+ });
+ };
+
+ AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo);
+ AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
+ AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
+ AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo);
+ AddStep("Deselect all", () => modSelector.DeselectAll());
+ AddStep("null ruleset", () => ruleset.Value = null);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
new file mode 100644
index 0000000000..546f6ac182
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
@@ -0,0 +1,23 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Overlays;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneNewsOverlay : OsuTestScene
+ {
+ private NewsOverlay news;
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ Add(news = new NewsOverlay());
+ AddStep(@"Show", news.Show);
+ AddStep(@"Hide", news.Hide);
+
+ AddStep(@"Show front page", () => news.ShowFrontPage());
+ AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs
index db6afa9bf3..cd954cd6bd 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Rankings;
using osu.Game.Users;
using osuTK;
@@ -45,7 +46,7 @@ namespace osu.Game.Tests.Visual.Online
Size = new Vector2(30, 20),
Country = countryA,
},
- text = new SpriteText
+ text = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
new file mode 100644
index 0000000000..93da2a439e
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
@@ -0,0 +1,129 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Overlays.Rankings.Tables;
+using osu.Framework.Graphics;
+using osu.Game.Online.API.Requests;
+using osu.Game.Rulesets;
+using osu.Game.Graphics.UserInterface;
+using System.Threading;
+using osu.Game.Online.API;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Mania;
+using osu.Game.Rulesets.Taiko;
+using osu.Game.Rulesets.Catch;
+using osu.Framework.Allocation;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneRankingsTables : OsuTestScene
+ {
+ protected override bool UseOnlineAPI => true;
+
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(PerformanceTable),
+ typeof(ScoresTable),
+ typeof(CountriesTable),
+ typeof(TableRowBackground),
+ typeof(UserBasedTable),
+ typeof(RankingsTable<>)
+ };
+
+ [Resolved]
+ private IAPIProvider api { get; set; }
+
+ private readonly BasicScrollContainer scrollFlow;
+ private readonly DimmedLoadingLayer loading;
+ private CancellationTokenSource cancellationToken;
+ private APIRequest request;
+
+ public TestSceneRankingsTables()
+ {
+ Children = new Drawable[]
+ {
+ scrollFlow = new BasicScrollContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ Width = 0.8f,
+ },
+ loading = new DimmedLoadingLayer(),
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ AddStep("Osu performance", () => createPerformanceTable(new OsuRuleset().RulesetInfo, null));
+ AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo));
+ AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo));
+ AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10));
+ }
+
+ private void createCountryTable(RulesetInfo ruleset, int page = 1)
+ {
+ onLoadStarted();
+
+ request = new GetCountryRankingsRequest(ruleset, page);
+ ((GetCountryRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new CountriesTable(page, rankings.Countries);
+ loadTable(table);
+ });
+
+ api.Queue(request);
+ }
+
+ private void createPerformanceTable(RulesetInfo ruleset, string country, int page = 1)
+ {
+ onLoadStarted();
+
+ request = new GetUserRankingsRequest(ruleset, country: country, page: page);
+ ((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new PerformanceTable(page, rankings.Users);
+ loadTable(table);
+ });
+
+ api.Queue(request);
+ }
+
+ private void createScoreTable(RulesetInfo ruleset, int page = 1)
+ {
+ onLoadStarted();
+
+ request = new GetUserRankingsRequest(ruleset, UserRankingsType.Score, page);
+ ((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new ScoresTable(page, rankings.Users);
+ loadTable(table);
+ });
+
+ api.Queue(request);
+ }
+
+ private void onLoadStarted()
+ {
+ loading.Show();
+ request?.Cancel();
+ cancellationToken?.Cancel();
+ cancellationToken = new CancellationTokenSource();
+ }
+
+ private void loadTable(Drawable table)
+ {
+ LoadComponentAsync(table, t =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(t);
+ loading.Hide();
+ }, cancellationToken.Token);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
index b26de1984a..b19f2dbf31 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
@@ -9,9 +9,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Scores;
-using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
-using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Users;
using osuTK.Graphics;
@@ -66,12 +64,12 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"ES",
},
},
- Mods = new Mod[]
+ Mods = new[]
{
- new OsuModDoubleTime(),
- new OsuModHidden(),
- new OsuModFlashlight(),
- new OsuModHardRock(),
+ new OsuModDoubleTime().Acronym,
+ new OsuModHidden().Acronym,
+ new OsuModFlashlight().Acronym,
+ new OsuModHardRock().Acronym,
},
Rank = ScoreRank.XH,
PP = 200,
@@ -91,11 +89,11 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"BR",
},
},
- Mods = new Mod[]
+ Mods = new[]
{
- new OsuModDoubleTime(),
- new OsuModHidden(),
- new OsuModFlashlight(),
+ new OsuModDoubleTime().Acronym,
+ new OsuModHidden().Acronym,
+ new OsuModFlashlight().Acronym,
},
Rank = ScoreRank.S,
PP = 190,
@@ -115,10 +113,10 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"JP",
},
},
- Mods = new Mod[]
+ Mods = new[]
{
- new OsuModDoubleTime(),
- new OsuModHidden(),
+ new OsuModDoubleTime().Acronym,
+ new OsuModHidden().Acronym,
},
Rank = ScoreRank.B,
PP = 180,
@@ -138,9 +136,9 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"CA",
},
},
- Mods = new Mod[]
+ Mods = new[]
{
- new OsuModDoubleTime(),
+ new OsuModDoubleTime().Acronym,
},
Rank = ScoreRank.C,
PP = 170,
@@ -208,12 +206,12 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"ES",
},
},
- Mods = new Mod[]
+ Mods = new[]
{
- new OsuModDoubleTime(),
- new OsuModHidden(),
- new OsuModFlashlight(),
- new OsuModHardRock(),
+ new OsuModDoubleTime().Acronym,
+ new OsuModHidden().Acronym,
+ new OsuModFlashlight().Acronym,
+ new OsuModHardRock().Acronym,
},
Rank = ScoreRank.XH,
PP = 200,
@@ -226,10 +224,13 @@ namespace osu.Game.Tests.Visual.Online
foreach (var s in allScores.Scores)
{
- s.Statistics.Add(HitResult.Great, RNG.Next(2000));
- s.Statistics.Add(HitResult.Good, RNG.Next(2000));
- s.Statistics.Add(HitResult.Meh, RNG.Next(2000));
- s.Statistics.Add(HitResult.Miss, RNG.Next(2000));
+ s.Statistics = new Dictionary
+ {
+ { "count_300", RNG.Next(2000) },
+ { "count_100", RNG.Next(2000) },
+ { "count_50", RNG.Next(2000) },
+ { "count_miss", RNG.Next(2000) }
+ };
}
AddStep("Load all scores", () =>
diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
index bccb263600..b9fbbfef6b 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
@@ -1,10 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Game.Overlays.Profile.Sections;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
+using osu.Game.Graphics.UserInterface;
+using osu.Framework.Allocation;
+using osu.Game.Graphics;
namespace osu.Game.Tests.Visual.Online
{
@@ -17,11 +19,11 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneShowMoreButton()
{
- ShowMoreButton button = null;
+ TestButton button = null;
int fireCount = 0;
- Add(button = new ShowMoreButton
+ Add(button = new TestButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@@ -51,5 +53,16 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);
}
+
+ private class TestButton : ShowMoreButton
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colors)
+ {
+ IdleColour = colors.YellowDark;
+ HoverColour = colors.Yellow;
+ ChevronIconColour = colors.Red;
+ }
+ }
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs b/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
index 3c5641fcd6..28b5693ef4 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
@@ -6,6 +6,11 @@ using osu.Framework.Graphics;
using osu.Game.Online.Chat;
using osu.Game.Users;
using osuTK;
+using System;
+using System.Linq;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Graphics.Containers;
+using osu.Game.Overlays.Chat;
namespace osu.Game.Tests.Visual.Online
{
@@ -41,14 +46,14 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private ChannelManager channelManager = new ChannelManager();
- private readonly StandAloneChatDisplay chatDisplay;
- private readonly StandAloneChatDisplay chatDisplay2;
+ private readonly TestStandAloneChatDisplay chatDisplay;
+ private readonly TestStandAloneChatDisplay chatDisplay2;
public TestSceneStandAloneChatDisplay()
{
Add(channelManager);
- Add(chatDisplay = new StandAloneChatDisplay
+ Add(chatDisplay = new TestStandAloneChatDisplay
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
@@ -56,7 +61,7 @@ namespace osu.Game.Tests.Visual.Online
Size = new Vector2(400, 80)
});
- Add(chatDisplay2 = new StandAloneChatDisplay(true)
+ Add(chatDisplay2 = new TestStandAloneChatDisplay(true)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
@@ -111,6 +116,60 @@ namespace osu.Game.Tests.Visual.Online
Sender = longUsernameUser,
Content = "Hi guys, my new username is lit!"
}));
+
+ AddStep("message with new date", () => testChannel.AddNewMessages(new Message(sequence++)
+ {
+ Sender = longUsernameUser,
+ Content = "Message from the future!",
+ Timestamp = DateTimeOffset.Now
+ }));
+
+ AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
+
+ const int messages_per_call = 10;
+ AddRepeatStep("add many messages", () =>
+ {
+ for (int i = 0; i < messages_per_call; i++)
+ {
+ testChannel.AddNewMessages(new Message(sequence++)
+ {
+ Sender = longUsernameUser,
+ Content = "Many messages! " + Guid.NewGuid(),
+ Timestamp = DateTimeOffset.Now
+ });
+ }
+ }, Channel.MAX_HISTORY / messages_per_call + 5);
+
+ AddAssert("Ensure no adjacent day separators", () =>
+ {
+ var indices = chatDisplay.FillFlow.OfType().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
+
+ foreach (var i in indices)
+ {
+ if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DrawableChannel.DaySeparator)
+ return false;
+ }
+
+ return true;
+ });
+
+ AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
+ }
+
+ private class TestStandAloneChatDisplay : StandAloneChatDisplay
+ {
+ public TestStandAloneChatDisplay(bool textbox = false)
+ : base(textbox)
+ {
+ }
+
+ protected DrawableChannel DrawableChannel => InternalChildren.OfType().First();
+
+ protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
+
+ public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
+
+ public bool ScrolledToBottom => ScrollContainer.IsScrolledToEnd(1);
}
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs b/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs
new file mode 100644
index 0000000000..4702d24125
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics;
+using osu.Framework.Bindables;
+using osu.Game.Overlays.Comments;
+using osu.Framework.MathUtils;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneTotalCommentsCounter : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(TotalCommentsCounter),
+ };
+
+ public TestSceneTotalCommentsCounter()
+ {
+ var count = new BindableInt();
+
+ Add(new TotalCommentsCounter
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Current = { BindTarget = count }
+ });
+
+ AddStep(@"Set 100", () => count.Value = 100);
+ AddStep(@"Set 0", () => count.Value = 0);
+ AddStep(@"Set random", () => count.Value = RNG.Next(0, int.MaxValue));
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs
index 18d6028cb8..0f41247571 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs
@@ -11,7 +11,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Mania;
using osu.Game.Users;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Taiko;
using osu.Game.Graphics.UserInterface;
@@ -94,11 +94,11 @@ namespace osu.Game.Tests.Visual.Online
AddRange(new Drawable[]
{
- new SpriteText
+ new OsuSpriteText
{
Text = $@"Username: {user.NewValue?.Username}"
},
- new SpriteText
+ new OsuSpriteText
{
Text = $@"RankedScore: {user.NewValue?.Statistics.RankedScore}"
},
diff --git a/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs b/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs
new file mode 100644
index 0000000000..8197cf72de
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs
@@ -0,0 +1,76 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Game.Overlays.Comments;
+using osu.Game.Online.API.Requests.Responses;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ [TestFixture]
+ public class TestSceneVotePill : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(VotePill)
+ };
+
+ private VotePill votePill;
+
+ [Test]
+ public void TestUserCommentPill()
+ {
+ AddStep("Log in", logIn);
+ AddStep("User comment", () => addVotePill(getUserComment()));
+ AddStep("Click", () => votePill.Click());
+ AddAssert("Not loading", () => !votePill.IsLoading);
+ }
+
+ [Test]
+ public void TestRandomCommentPill()
+ {
+ AddStep("Log in", logIn);
+ AddStep("Random comment", () => addVotePill(getRandomComment()));
+ AddStep("Click", () => votePill.Click());
+ AddAssert("Loading", () => votePill.IsLoading);
+ }
+
+ [Test]
+ public void TestOfflineRandomCommentPill()
+ {
+ AddStep("Log out", API.Logout);
+ AddStep("Random comment", () => addVotePill(getRandomComment()));
+ AddStep("Click", () => votePill.Click());
+ AddAssert("Not loading", () => !votePill.IsLoading);
+ }
+
+ private void logIn() => API.Login("localUser", "password");
+
+ private Comment getUserComment() => new Comment
+ {
+ IsVoted = false,
+ UserId = API.LocalUser.Value.Id,
+ VotesCount = 10,
+ };
+
+ private Comment getRandomComment() => new Comment
+ {
+ IsVoted = false,
+ UserId = 4444,
+ VotesCount = 2,
+ };
+
+ private void addVotePill(Comment comment)
+ {
+ Clear();
+ Add(votePill = new VotePill(comment)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
new file mode 100644
index 0000000000..e3dae9c27e
--- /dev/null
+++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
@@ -0,0 +1,65 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Configuration;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Settings
+{
+ [TestFixture]
+ public class TestSceneSettingsSource : OsuTestScene
+ {
+ public TestSceneSettingsSource()
+ {
+ Children = new Drawable[]
+ {
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Direction = FillDirection.Vertical,
+ Spacing = new Vector2(20),
+ Width = 0.5f,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Padding = new MarginPadding(50),
+ ChildrenEnumerable = new TestTargetClass().CreateSettingsControls()
+ },
+ };
+ }
+
+ private class TestTargetClass
+ {
+ [SettingSource("Sample bool", "Clicking this changes a setting")]
+ public BindableBool TickBindable { get; } = new BindableBool();
+
+ [SettingSource("Sample float", "Change something for a mod")]
+ public BindableFloat SliderBindable { get; } = new BindableFloat
+ {
+ MinValue = 0,
+ MaxValue = 10,
+ Default = 5,
+ Value = 7
+ };
+
+ [SettingSource("Sample enum", "Change something for a mod")]
+ public Bindable EnumBindable { get; } = new Bindable
+ {
+ Default = TestEnum.Value1,
+ Value = TestEnum.Value2
+ };
+
+ [SettingSource("Sample string", "Change something for a mod")]
+ public Bindable StringBindable { get; } = new Bindable();
+ }
+
+ private enum TestEnum
+ {
+ Value1,
+ Value2
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
index f87d6ebebb..132b104afb 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
@@ -10,6 +10,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets;
@@ -51,11 +52,6 @@ namespace osu.Game.Tests.Visual.SongSelect
private void load(RulesetStore rulesets)
{
this.rulesets = rulesets;
-
- Add(carousel = new TestBeatmapCarousel
- {
- RelativeSizeAxes = Axes.Both,
- });
}
///
@@ -245,6 +241,28 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
}
+ [Test]
+ public void TestSortingStability()
+ {
+ var sets = new List();
+
+ for (int i = 0; i < 20; i++)
+ {
+ var set = createTestBeatmapSet(i);
+ set.Metadata.Artist = "same artist";
+ set.Metadata.Title = "same title";
+ sets.Add(set);
+ }
+
+ loadBeatmaps(sets);
+
+ AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
+ AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
+
+ AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false));
+ AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
+ }
+
[Test]
public void TestSortingWithFiltered()
{
@@ -316,10 +334,19 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestHiding()
{
- BeatmapSetInfo hidingSet = createTestBeatmapSet(1);
- hidingSet.Beatmaps[1].Hidden = true;
+ BeatmapSetInfo hidingSet = null;
+ List hiddenList = new List();
- loadBeatmaps(new List { hidingSet });
+ AddStep("create hidden set", () =>
+ {
+ hidingSet = createTestBeatmapSet(1);
+ hidingSet.Beatmaps[1].Hidden = true;
+
+ hiddenList.Clear();
+ hiddenList.Add(hidingSet);
+ });
+
+ loadBeatmaps(hiddenList);
setSelected(1, 1);
@@ -353,9 +380,14 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test]
public void TestSelectingFilteredRuleset()
{
- var testMixed = createTestBeatmapSet(set_count + 1);
+ BeatmapSetInfo testMixed = null;
+
+ createCarousel();
+
AddStep("add mixed ruleset beatmapset", () =>
{
+ testMixed = createTestBeatmapSet(set_count + 1);
+
for (int i = 0; i <= 2; i++)
{
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
@@ -407,6 +439,8 @@ namespace osu.Game.Tests.Visual.SongSelect
private void loadBeatmaps(List beatmapSets = null)
{
+ createCarousel();
+
if (beatmapSets == null)
{
beatmapSets = new List();
@@ -426,6 +460,20 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Wait for load", () => changed);
}
+ private void createCarousel(Container target = null)
+ {
+ AddStep("Create carousel", () =>
+ {
+ selectedSets.Clear();
+ eagerSelectedIDs.Clear();
+
+ (target ?? this).Child = carousel = new TestBeatmapCarousel
+ {
+ RelativeSizeAxes = Axes.Both,
+ };
+ });
+ }
+
private void ensureRandomFetchSuccess() =>
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);
@@ -445,8 +493,10 @@ namespace osu.Game.Tests.Visual.SongSelect
private void advanceSelection(bool diff, int direction = 1, int count = 1)
{
if (count == 1)
+ {
AddStep($"select {(direction > 0 ? "next" : "prev")} {(diff ? "diff" : "set")}", () =>
carousel.SelectNext(direction, !diff));
+ }
else
{
AddRepeatStep($"select {(direction > 0 ? "next" : "prev")} {(diff ? "diff" : "set")}", () =>
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
index fb27ec7654..57e297bcd5 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
@@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
-using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
@@ -62,7 +61,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
- Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
+ Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User
{
Id = 6602580,
diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
index a7020b6534..5dd02c1ddd 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
@@ -57,23 +57,6 @@ namespace osu.Game.Tests.Visual.SongSelect
typeof(DrawableCarouselBeatmapSet),
};
- private class TestSongSelect : PlaySongSelect
- {
- public Action StartRequested;
-
- public new Bindable Ruleset => base.Ruleset;
-
- public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
- public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
- public new BeatmapCarousel Carousel => base.Carousel;
-
- protected override bool OnStart()
- {
- StartRequested?.Invoke();
- return base.OnStart();
- }
- }
-
private TestSongSelect songSelect;
[BackgroundDependencyLoader]
@@ -101,6 +84,53 @@ namespace osu.Game.Tests.Visual.SongSelect
manager?.Delete(manager.GetAllUsableBeatmapSets());
});
+ [Test]
+ public void TestSingleFilterOnEnter()
+ {
+ addRulesetImportStep(0);
+ addRulesetImportStep(0);
+
+ createSongSelect();
+
+ AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
+ }
+
+ [Test]
+ public void TestNoFilterOnSimpleResume()
+ {
+ addRulesetImportStep(0);
+ addRulesetImportStep(0);
+
+ createSongSelect();
+
+ AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
+ AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
+
+ AddStep("return", () => songSelect.MakeCurrent());
+ AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
+ AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
+ }
+
+ [Test]
+ public void TestFilterOnResumeAfterChange()
+ {
+ addRulesetImportStep(0);
+ addRulesetImportStep(0);
+
+ AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, false));
+
+ createSongSelect();
+
+ AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
+ AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
+
+ AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, true));
+
+ AddStep("return", () => songSelect.MakeCurrent());
+ AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
+ AddAssert("filter count is 2", () => songSelect.FilterCount == 2);
+ }
+
[Test]
public void TestAudioResuming()
{
@@ -132,11 +162,13 @@ namespace osu.Game.Tests.Visual.SongSelect
changeRuleset(1);
if (rulesetsInSameBeatmap)
+ {
AddStep("import multi-ruleset map", () =>
{
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
manager.Import(createTestBeatmapSet(0, usableRulesets)).Wait();
});
+ }
else
{
addRulesetImportStep(1);
@@ -240,6 +272,22 @@ namespace osu.Game.Tests.Visual.SongSelect
void onRulesetChange(ValueChangedEvent e) => rulesetChangeIndex = actionIndex++;
}
+ [Test]
+ public void TestModsRetainedBetweenSongSelect()
+ {
+ AddAssert("empty mods", () => !Mods.Value.Any());
+
+ createSongSelect();
+
+ addRulesetImportStep(0);
+
+ changeMods(new OsuModHardRock());
+
+ createSongSelect();
+
+ AddAssert("mods retained", () => Mods.Value.Any());
+ }
+
[Test]
public void TestStartAfterUnMatchingFilterDoesNotStart()
{
@@ -349,5 +397,36 @@ namespace osu.Game.Tests.Visual.SongSelect
DateAdded = DateTimeOffset.UtcNow,
};
}
+
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ rulesets?.Dispose();
+ }
+
+ private class TestSongSelect : PlaySongSelect
+ {
+ public Action StartRequested;
+
+ public new Bindable Ruleset => base.Ruleset;
+
+ public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
+ public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
+ public new BeatmapCarousel Carousel => base.Carousel;
+
+ protected override bool OnStart()
+ {
+ StartRequested?.Invoke();
+ return base.OnStart();
+ }
+
+ public int FilterCount;
+
+ protected override void ApplyFilterToCarousel(FilterCriteria criteria)
+ {
+ FilterCount++;
+ base.ApplyFilterToCarousel(criteria);
+ }
+ }
}
}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
index 7fac45e0f1..e34e1844ce 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneUserTopScoreContainer.cs
@@ -7,7 +7,6 @@ using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
-using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users;
@@ -52,7 +51,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
- Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
+ Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User
{
Id = 6602580,
diff --git a/osu.Game.Tests/Visual/TestSceneOsuGame.cs b/osu.Game.Tests/Visual/TestSceneOsuGame.cs
index fcc3a3596f..e495b2a95a 100644
--- a/osu.Game.Tests/Visual/TestSceneOsuGame.cs
+++ b/osu.Game.Tests/Visual/TestSceneOsuGame.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
private IReadOnlyList requiredGameDependencies => new[]
{
typeof(OsuGame),
- typeof(RavenLogger),
+ typeof(SentryLogger),
typeof(OsuLogo),
typeof(IdleTracker),
typeof(OnScreenDisplay),
@@ -109,16 +109,20 @@ namespace osu.Game.Tests.Visual
AddAssert("check OsuGame DI members", () =>
{
foreach (var type in requiredGameDependencies)
+ {
if (game.Dependencies.Get(type) == null)
throw new Exception($"{type} has not been cached");
+ }
return true;
});
AddAssert("check OsuGameBase DI members", () =>
{
foreach (var type in requiredGameBaseDependencies)
+ {
if (gameBase.Dependencies.Get(type) == null)
throw new Exception($"{type} has not been cached");
+ }
return true;
});
diff --git a/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs b/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
index a68fd0ef40..c55988d1bb 100644
--- a/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
+++ b/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
AddAssert("Parallax is off", () => stack.ParallaxAmount == 0);
}
- private class TestScreen : ScreenWithBeatmapBackground
+ public class TestScreen : ScreenWithBeatmapBackground
{
private readonly string screenText;
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs
index d84ffa0d93..ed44d82bce 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
@@ -10,7 +11,6 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Lists;
using osu.Framework.Timing;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
@@ -153,7 +153,7 @@ namespace osu.Game.Tests.Visual.UserInterface
};
}
- private SortedList timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints;
+ private List timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.ToList();
private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
{
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs
similarity index 82%
rename from osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs
rename to osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs
index 700adad9cb..8179f92ffc 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledComponent.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs
@@ -11,7 +11,7 @@ using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
- public class TestSceneLabelledComponent : OsuTestScene
+ public class TestSceneLabelledDrawable : OsuTestScene
{
[TestCase(false)]
[TestCase(true)]
@@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("create component", () =>
{
- LabelledComponent component;
+ LabelledDrawable component;
Child = new Container
{
@@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
- Child = component = padded ? (LabelledComponent)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
+ Child = component = padded ? (LabelledDrawable)new PaddedLabelledDrawable() : new NonPaddedLabelledDrawable(),
};
component.Label = "a sample component";
@@ -41,9 +41,9 @@ namespace osu.Game.Tests.Visual.UserInterface
});
}
- private class PaddedLabelledComponent : LabelledComponent
+ private class PaddedLabelledDrawable : LabelledDrawable
{
- public PaddedLabelledComponent()
+ public PaddedLabelledDrawable()
: base(true)
{
}
@@ -57,9 +57,9 @@ namespace osu.Game.Tests.Visual.UserInterface
};
}
- private class NonPaddedLabelledComponent : LabelledComponent
+ private class NonPaddedLabelledDrawable : LabelledDrawable
{
- public NonPaddedLabelledComponent()
+ public NonPaddedLabelledDrawable()
: base(false)
{
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledTextBox.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledTextBox.cs
index 53a2bfabbc..8208b55952 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledTextBox.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledTextBox.cs
@@ -7,7 +7,6 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Tests.Visual.UserInterface
@@ -28,7 +27,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("create component", () =>
{
- LabelledComponent component;
+ LabelledTextBox component;
Child = new Container
{
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs
new file mode 100644
index 0000000000..fc44c5f595
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs
@@ -0,0 +1,107 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Linq;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Configuration;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Overlays.Mods;
+using osu.Game.Rulesets.Mods;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneModSettings : OsuTestScene
+ {
+ private TestModSelectOverlay modSelect;
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Add(modSelect = new TestModSelectOverlay
+ {
+ RelativeSizeAxes = Axes.X,
+ Origin = Anchor.BottomCentre,
+ Anchor = Anchor.BottomCentre,
+ });
+
+ var testMod = new TestModCustomisable1();
+
+ AddStep("open", modSelect.Show);
+ AddAssert("button disabled", () => !modSelect.CustomiseButton.Enabled.Value);
+ AddUntilStep("wait for button load", () => modSelect.ButtonsLoaded);
+ AddStep("select mod", () => modSelect.SelectMod(testMod));
+ AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
+ AddStep("open Customisation", () => modSelect.CustomiseButton.Click());
+ AddStep("deselect mod", () => modSelect.SelectMod(testMod));
+ AddAssert("controls hidden", () => modSelect.ModSettingsContainer.Alpha == 0);
+ }
+
+ private class TestModSelectOverlay : ModSelectOverlay
+ {
+ public new Container ModSettingsContainer => base.ModSettingsContainer;
+ public new TriangleButton CustomiseButton => base.CustomiseButton;
+
+ public bool ButtonsLoaded => ModSectionsContainer.Children.All(c => c.ModIconsLoaded);
+
+ public void SelectMod(Mod mod) =>
+ ModSectionsContainer.Children.Single(s => s.ModType == mod.Type)
+ .ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())).SelectNext(1);
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ foreach (var section in ModSectionsContainer)
+ {
+ if (section.ModType == ModType.Conversion)
+ {
+ section.Mods = new Mod[]
+ {
+ new TestModCustomisable1(),
+ new TestModCustomisable2()
+ };
+ }
+ else
+ section.Mods = Array.Empty();
+ }
+ }
+ }
+
+ private class TestModCustomisable1 : TestModCustomisable
+ {
+ public override string Name => "Customisable Mod 1";
+
+ public override string Acronym => "CM1";
+ }
+
+ private class TestModCustomisable2 : TestModCustomisable
+ {
+ public override string Name => "Customisable Mod 2";
+
+ public override string Acronym => "CM2";
+ }
+
+ private abstract class TestModCustomisable : Mod, IApplicableMod
+ {
+ public override double ScoreMultiplier => 1.0;
+
+ public override ModType Type => ModType.Conversion;
+
+ [SettingSource("Sample float", "Change something for a mod")]
+ public BindableFloat SliderBindable { get; } = new BindableFloat
+ {
+ MinValue = 0,
+ MaxValue = 10,
+ Default = 5,
+ Value = 7
+ };
+
+ [SettingSource("Sample bool", "Clicking this changes a setting")]
+ public BindableBool TickBindable { get; } = new BindableBool();
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs
index 3d39bb7003..7207506ccd 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs
@@ -1,9 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
+using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Tests.Visual.UserInterface
@@ -11,13 +14,22 @@ namespace osu.Game.Tests.Visual.UserInterface
[TestFixture]
public class TestScenePopupDialog : OsuTestScene
{
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(PopupDialogOkButton),
+ typeof(PopupDialogCancelButton),
+ typeof(PopupDialogButton),
+ typeof(DialogButton),
+ };
+
public TestScenePopupDialog()
{
- Add(new TestPopupDialog
- {
- RelativeSizeAxes = Axes.Both,
- State = { Value = Framework.Graphics.Containers.Visibility.Visible },
- });
+ AddStep("new popup", () =>
+ Add(new TestPopupDialog
+ {
+ RelativeSizeAxes = Axes.Both,
+ State = { Value = Framework.Graphics.Containers.Visibility.Visible },
+ }));
}
private class TestPopupDialog : PopupDialog
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs
new file mode 100644
index 0000000000..2ada5b927b
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs
@@ -0,0 +1,145 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneStatefulMenuItem : ManualInputManagerTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(OsuMenu),
+ typeof(StatefulMenuItem),
+ typeof(TernaryStateMenuItem),
+ typeof(DrawableStatefulMenuItem),
+ };
+
+ [Test]
+ public void TestTernaryMenuItem()
+ {
+ OsuMenu menu = null;
+
+ Bindable state = new Bindable(TernaryState.Indeterminate);
+
+ AddStep("create menu", () =>
+ {
+ state.Value = TernaryState.Indeterminate;
+
+ Child = menu = new OsuMenu(Direction.Vertical, true)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Items = new[]
+ {
+ new TernaryStateMenuItem("First"),
+ new TernaryStateMenuItem("Second") { State = { BindTarget = state } },
+ new TernaryStateMenuItem("Third") { State = { Value = TernaryState.True } },
+ }
+ };
+ });
+
+ checkState(TernaryState.Indeterminate);
+
+ click();
+ checkState(TernaryState.True);
+
+ click();
+ checkState(TernaryState.False);
+
+ click();
+ checkState(TernaryState.True);
+
+ click();
+ checkState(TernaryState.False);
+
+ AddStep("change state via bindable", () => state.Value = TernaryState.True);
+
+ void click() =>
+ AddStep("click", () =>
+ {
+ InputManager.MoveMouseTo(menu.ScreenSpaceDrawQuad.Centre);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ void checkState(TernaryState expected)
+ => AddAssert($"state is {expected}", () => state.Value == expected);
+ }
+
+ [Test]
+ public void TestCustomState()
+ {
+ AddStep("create menu", () =>
+ {
+ Child = new OsuMenu(Direction.Vertical, true)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Items = new[]
+ {
+ new TestMenuItem("First", MenuItemType.Standard, getNextState),
+ new TestMenuItem("Second", MenuItemType.Standard, getNextState) { State = { Value = TestStates.State2 } },
+ new TestMenuItem("Third", MenuItemType.Standard, getNextState) { State = { Value = TestStates.State3 } },
+ }
+ };
+ });
+ }
+
+ private TestStates getNextState(TestStates state)
+ {
+ switch (state)
+ {
+ case TestStates.State1:
+ return TestStates.State2;
+
+ case TestStates.State2:
+ return TestStates.State3;
+
+ case TestStates.State3:
+ return TestStates.State1;
+ }
+
+ return TestStates.State1;
+ }
+
+ private class TestMenuItem : StatefulMenuItem
+ {
+ public TestMenuItem(string text, MenuItemType type, Func changeStateFunc)
+ : base(text, changeStateFunc, type)
+ {
+ }
+
+ public override IconUsage? GetIconForState(TestStates state)
+ {
+ switch (state)
+ {
+ case TestStates.State1:
+ return FontAwesome.Solid.DiceOne;
+
+ case TestStates.State2:
+ return FontAwesome.Solid.DiceTwo;
+
+ case TestStates.State3:
+ return FontAwesome.Solid.DiceThree;
+
+ default:
+ throw new ArgumentOutOfRangeException(nameof(state), state, null);
+ }
+ }
+ }
+
+ private enum TestStates
+ {
+ State1,
+ State2,
+ State3
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneToggleMenuItem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneToggleMenuItem.cs
new file mode 100644
index 0000000000..2abda56a28
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneToggleMenuItem.cs
@@ -0,0 +1,34 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics;
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneToggleMenuItem : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(OsuMenu),
+ typeof(ToggleMenuItem),
+ typeof(DrawableStatefulMenuItem)
+ };
+
+ public TestSceneToggleMenuItem()
+ {
+ Add(new OsuMenu(Direction.Vertical, true)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Items = new[]
+ {
+ new ToggleMenuItem("First"),
+ new ToggleMenuItem("Second") { State = { Value = true } }
+ }
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj
index aa29fc802c..c5998c9cfc 100644
--- a/osu.Game.Tests/osu.Game.Tests.csproj
+++ b/osu.Game.Tests/osu.Game.Tests.csproj
@@ -3,7 +3,7 @@
-
+
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneTournamentMatchChatDisplay.cs b/osu.Game.Tournament.Tests/Components/TestSceneTournamentMatchChatDisplay.cs
index 41d32d9448..9905e17824 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneTournamentMatchChatDisplay.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneTournamentMatchChatDisplay.cs
@@ -102,7 +102,8 @@ namespace osu.Game.Tournament.Tests.Components
Content = "Okay okay, calm down guys. Let's do this!"
}));
- AddStep("multiple messages", () => testChannel.AddNewMessages(new Message(nextMessageId())
+ AddStep("multiple messages", () => testChannel.AddNewMessages(
+ new Message(nextMessageId())
{
Sender = admin,
Content = "I spam you!"
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
index 3d340e393c..e36b594ff2 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
@@ -3,7 +3,6 @@
using System.Linq;
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.TeamIntro;
@@ -13,7 +12,7 @@ namespace osu.Game.Tournament.Tests.Screens
public class TestSceneTeamIntroScreen : LadderTestScene
{
[Cached]
- private readonly Bindable currentMatch = new Bindable();
+ private readonly LadderInfo ladder = new LadderInfo();
[BackgroundDependencyLoader]
private void load()
@@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Tests.Screens
match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
- currentMatch.Value = match;
+ ladder.CurrentMatch.Value = match;
Add(new TeamIntroScreen
{
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
index 6f5e17a36e..5cb35a506f 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
@@ -3,7 +3,6 @@
using System.Linq;
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.TeamWin;
@@ -13,7 +12,7 @@ namespace osu.Game.Tournament.Tests.Screens
public class TestSceneTeamWinScreen : LadderTestScene
{
[Cached]
- private readonly Bindable currentMatch = new Bindable();
+ private readonly LadderInfo ladder = new LadderInfo();
[BackgroundDependencyLoader]
private void load()
@@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Tests.Screens
match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
- currentMatch.Value = match;
+ ladder.CurrentMatch.Value = match;
Add(new TeamWinScreen
{
diff --git a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
index 371ffcdf9e..d58a724c27 100644
--- a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
+++ b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs
index 7005c068ae..8a46da9565 100644
--- a/osu.Game.Tournament/Components/SongBar.cs
+++ b/osu.Game.Tournament/Components/SongBar.cs
@@ -3,6 +3,7 @@
using System;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -13,6 +14,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using osuTK;
using osuTK.Graphics;
@@ -23,6 +25,9 @@ namespace osu.Game.Tournament.Components
{
private BeatmapInfo beatmap;
+ [Resolved]
+ private IBindable ruleset { get; set; }
+
public BeatmapInfo Beatmap
{
get => beatmap;
@@ -106,6 +111,7 @@ namespace osu.Game.Tournament.Components
Width = main_width,
Height = TournamentBeatmapPanel.HEIGHT,
CornerRadius = TournamentBeatmapPanel.HEIGHT / 2,
+ CornerExponent = 2,
Children = new Drawable[]
{
new Box
@@ -126,6 +132,7 @@ namespace osu.Game.Tournament.Components
{
Masking = true,
CornerRadius = TournamentBeatmapPanel.HEIGHT / 2,
+ CornerExponent = 2,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
@@ -163,7 +170,8 @@ namespace osu.Game.Tournament.Components
string hardRockExtra = "";
string srExtra = "";
- //var ar = beatmap.BaseDifficulty.ApproachRate;
+ var ar = beatmap.BaseDifficulty.ApproachRate;
+
if ((mods & LegacyMods.HardRock) > 0)
{
hardRockExtra = "*";
@@ -172,12 +180,46 @@ namespace osu.Game.Tournament.Components
if ((mods & LegacyMods.DoubleTime) > 0)
{
- //ar *= 1.5f;
+ // temporary local calculation (taken from OsuDifficultyCalculator)
+ double preempt = (int)BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / 1.5;
+ ar = (float)(preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5);
+
bpm *= 1.5f;
length /= 1.5f;
srExtra = "*";
}
+ (string heading, string content)[] stats;
+
+ switch (ruleset.Value.ID)
+ {
+ default:
+ stats = new (string heading, string content)[]
+ {
+ ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
+ ("AR", $"{ar:0.#}{hardRockExtra}"),
+ ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
+ };
+ break;
+
+ case 1:
+ case 3:
+ stats = new (string heading, string content)[]
+ {
+ ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
+ ("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
+ };
+ break;
+
+ case 2:
+ stats = new (string heading, string content)[]
+ {
+ ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
+ ("AR", $"{ar:0.#}"),
+ };
+ break;
+ }
+
panelContents.Children = new Drawable[]
{
new DiffPiece(("Length", TimeSpan.FromMilliseconds(length).ToString(@"mm\:ss")))
@@ -190,12 +232,7 @@ namespace osu.Game.Tournament.Components
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopLeft
},
- new DiffPiece(
- //("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
- //("AR", $"{ar:0.#}{srExtra}"),
- ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
- ("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
- )
+ new DiffPiece(stats)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.BottomRight
@@ -222,7 +259,7 @@ namespace osu.Game.Tournament.Components
Margin = new MarginPadding { Horizontal = 15, Vertical = 1 };
AutoSizeAxes = Axes.Both;
- void cp(SpriteText s, Color4 colour)
+ static void cp(SpriteText s, Color4 colour)
{
s.Colour = colour;
s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15);
@@ -230,7 +267,7 @@ namespace osu.Game.Tournament.Components
for (var i = 0; i < tuples.Length; i++)
{
- var tuple = tuples[i];
+ var (heading, content) = tuples[i];
if (i > 0)
{
@@ -241,9 +278,9 @@ namespace osu.Game.Tournament.Components
});
}
- AddText(new OsuSpriteText { Text = tuple.heading }, s => cp(s, OsuColour.Gray(0.33f)));
+ AddText(new OsuSpriteText { Text = heading }, s => cp(s, OsuColour.Gray(0.33f)));
AddText(" ", s => cp(s, OsuColour.Gray(0.33f)));
- AddText(new OsuSpriteText { Text = tuple.content }, s => cp(s, OsuColour.Gray(0.5f)));
+ AddText(new OsuSpriteText { Text = content }, s => cp(s, OsuColour.Gray(0.5f)));
}
}
}
diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
index f6c1be0e36..51483a0964 100644
--- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
+++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
@@ -52,6 +52,7 @@ namespace osu.Game.Tournament.Components
currentMatch.BindTo(ladder.CurrentMatch);
CornerRadius = HEIGHT / 2;
+ CornerExponent = 2;
Masking = true;
AddRangeInternal(new Drawable[]
@@ -131,6 +132,7 @@ namespace osu.Game.Tournament.Components
});
if (!string.IsNullOrEmpty(mods))
+ {
AddInternal(new Sprite
{
Texture = textures.Get($"mods/{mods}"),
@@ -139,6 +141,7 @@ namespace osu.Game.Tournament.Components
Margin = new MarginPadding(20),
Scale = new Vector2(0.5f)
});
+ }
}
private void matchChanged(ValueChangedEvent match)
diff --git a/osu.Game.Tournament/Components/TourneyVideo.cs b/osu.Game.Tournament/Components/TourneyVideo.cs
index 4f4660f645..206689ca1a 100644
--- a/osu.Game.Tournament/Components/TourneyVideo.cs
+++ b/osu.Game.Tournament/Components/TourneyVideo.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Video;
+using osu.Framework.Timing;
using osu.Game.Graphics;
namespace osu.Game.Tournament.Components
@@ -15,6 +16,8 @@ namespace osu.Game.Tournament.Components
{
private readonly VideoSprite video;
+ private readonly ManualClock manualClock;
+
public TourneyVideo(Stream stream)
{
if (stream == null)
@@ -26,11 +29,14 @@ namespace osu.Game.Tournament.Components
};
}
else
+ {
InternalChild = video = new VideoSprite(stream)
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
+ Clock = new FramedClock(manualClock = new ManualClock())
};
+ }
}
public bool Loop
@@ -41,5 +47,17 @@ namespace osu.Game.Tournament.Components
video.Loop = value;
}
}
+
+ protected override void Update()
+ {
+ base.Update();
+
+ if (manualClock != null && Clock.ElapsedFrameTime < 100)
+ {
+ // we want to avoid seeking as much as possible, because we care about performance, not sync.
+ // to avoid seeking completely, we only increment out local clock when in an updating state.
+ manualClock.CurrentTime += Clock.ElapsedFrameTime;
+ }
+ }
}
}
diff --git a/osu.Game.Tournament/IPC/FileBasedIPC.cs b/osu.Game.Tournament/IPC/FileBasedIPC.cs
index e05d96e098..b19f2bedf0 100644
--- a/osu.Game.Tournament/IPC/FileBasedIPC.cs
+++ b/osu.Game.Tournament/IPC/FileBasedIPC.cs
@@ -60,6 +60,7 @@ namespace osu.Game.Tournament.IPC
const string file_ipc_channel_filename = "ipc-channel.txt";
if (Storage.Exists(file_ipc_filename))
+ {
scheduled = Scheduler.AddDelayed(delegate
{
try
@@ -134,6 +135,7 @@ namespace osu.Game.Tournament.IPC
// file might be in use.
}
}, 250, true);
+ }
}
catch (Exception e)
{
@@ -150,7 +152,7 @@ namespace osu.Game.Tournament.IPC
{
protected override string LocateBasePath()
{
- bool checkExists(string p)
+ static bool checkExists(string p)
{
return File.Exists(Path.Combine(p, "ipc.txt"));
}
@@ -178,7 +180,7 @@ namespace osu.Game.Tournament.IPC
try
{
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
- stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(String.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
+ stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
if (checkExists(stableInstallPath))
return stableInstallPath;
diff --git a/osu.Game.Tournament/Models/LadderInfo.cs b/osu.Game.Tournament/Models/LadderInfo.cs
index 547c4eab08..5db0b01547 100644
--- a/osu.Game.Tournament/Models/LadderInfo.cs
+++ b/osu.Game.Tournament/Models/LadderInfo.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Framework.Bindables;
+using osu.Game.Rulesets;
namespace osu.Game.Tournament.Models
{
@@ -14,6 +15,8 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class LadderInfo
{
+ public Bindable Ruleset = new Bindable();
+
public BindableList Matches = new BindableList();
public BindableList Rounds = new BindableList();
public BindableList Teams = new BindableList();
diff --git a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs
index 8a66ca7bf6..b9a19090df 100644
--- a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs
+++ b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs
@@ -57,7 +57,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
groups.Add(g);
nextGroupName++;
- if (i < (int)Math.Ceiling(numGroups / 2f))
+ if (i < (int)MathF.Ceiling(numGroups / 2f))
topGroups.Add(g);
else
bottomGroups.Add(g);
diff --git a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs
index b147d680f0..3ff4718b75 100644
--- a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs
+++ b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs
@@ -83,90 +83,81 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
};
}
- private ScrollState _scrollState;
+ private ScrollState scrollState;
- private ScrollState scrollState
+ private void setScrollState(ScrollState newstate)
{
- get => _scrollState;
+ if (scrollState == newstate)
+ return;
- set
+ delayedStateChangeDelegate?.Cancel();
+
+ switch (scrollState = newstate)
{
- if (_scrollState == value)
- return;
+ case ScrollState.Scrolling:
+ resetSelected();
- _scrollState = value;
+ OnScrollStarted?.Invoke();
- delayedStateChangeDelegate?.Cancel();
+ speedTo(1000f, 200);
+ tracker.FadeOut(100);
+ break;
- switch (value)
- {
- case ScrollState.Scrolling:
- resetSelected();
+ case ScrollState.Stopping:
+ speedTo(0f, 2000);
+ tracker.FadeIn(200);
- OnScrollStarted?.Invoke();
+ delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Stopped), 2300);
+ break;
- speedTo(1000f, 200);
- tracker.FadeOut(100);
+ case ScrollState.Stopped:
+ // Find closest to center
+ if (!Children.Any())
break;
- case ScrollState.Stopping:
- speedTo(0f, 2000);
- tracker.FadeIn(200);
+ ScrollingTeam closest = null;
- delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Stopped, 2300);
- break;
+ foreach (var c in Children)
+ {
+ if (!(c is ScrollingTeam stc))
+ continue;
- case ScrollState.Stopped:
- // Find closest to center
- if (!Children.Any())
- break;
-
- ScrollingTeam closest = null;
-
- foreach (var c in Children)
+ if (closest == null)
{
- var stc = c as ScrollingTeam;
-
- if (stc == null)
- continue;
-
- if (closest == null)
- {
- closest = stc;
- continue;
- }
-
- float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
- float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
-
- if (o < lastOffset)
- closest = stc;
+ closest = stc;
+ continue;
}
- Trace.Assert(closest != null, "closest != null");
+ float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
+ float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
- // ReSharper disable once PossibleNullReferenceException
- offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
+ if (o < lastOffset)
+ closest = stc;
+ }
- ScrollingTeam st = closest;
+ Trace.Assert(closest != null, "closest != null");
- availableTeams.RemoveAll(at => at == st.Team);
+ // ReSharper disable once PossibleNullReferenceException
+ offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
- st.Selected = true;
- OnSelected?.Invoke(st.Team);
+ ScrollingTeam st = closest;
- delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Idle, 10000);
- break;
+ availableTeams.RemoveAll(at => at == st.Team);
- case ScrollState.Idle:
- resetSelected();
+ st.Selected = true;
+ OnSelected?.Invoke(st.Team);
- OnScrollStarted?.Invoke();
+ delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000);
+ break;
- speedTo(40f, 200);
- tracker.FadeOut(100);
- break;
- }
+ case ScrollState.Idle:
+ resetSelected();
+
+ OnScrollStarted?.Invoke();
+
+ speedTo(40f, 200);
+ tracker.FadeOut(100);
+ break;
}
}
@@ -178,7 +169,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
availableTeams.Add(team);
RemoveAll(c => c is ScrollingTeam);
- scrollState = ScrollState.Idle;
+ setScrollState(ScrollState.Idle);
}
public void AddTeams(IEnumerable teams)
@@ -194,7 +185,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{
availableTeams.Clear();
RemoveAll(c => c is ScrollingTeam);
- scrollState = ScrollState.Idle;
+ setScrollState(ScrollState.Idle);
}
public void RemoveTeam(TournamentTeam team)
@@ -203,15 +194,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
foreach (var c in Children)
{
- ScrollingTeam st = c as ScrollingTeam;
-
- if (st == null)
- continue;
-
- if (st.Team == team)
+ if (c is ScrollingTeam st)
{
- st.FadeOut(200);
- st.Expire();
+ if (st.Team == team)
+ {
+ st.FadeOut(200);
+ st.Expire();
+ }
}
}
}
@@ -221,7 +210,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
if (availableTeams.Count == 0)
return;
- scrollState = ScrollState.Scrolling;
+ setScrollState(ScrollState.Scrolling);
}
public void StopScrolling()
@@ -236,13 +225,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
return;
}
- scrollState = ScrollState.Stopping;
+ setScrollState(ScrollState.Stopping);
}
protected override void LoadComplete()
{
base.LoadComplete();
- scrollState = ScrollState.Idle;
+ setScrollState(ScrollState.Idle);
}
protected override void UpdateAfterChildren()
@@ -295,14 +284,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{
foreach (var c in Children)
{
- ScrollingTeam st = c as ScrollingTeam;
- if (st == null)
- continue;
-
- if (st.Selected)
+ if (c is ScrollingTeam st)
{
- st.Selected = false;
- RemoveTeam(st.Team);
+ if (st.Selected)
+ {
+ st.Selected = false;
+ RemoveTeam(st.Team);
+ }
}
}
}
@@ -310,7 +298,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
this.TransformTo(nameof(speed), value, duration, easing);
- private enum ScrollState
+ protected enum ScrollState
{
None,
Idle,
diff --git a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
index 3a14b6d9c2..5efa0a1e69 100644
--- a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
+++ b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
@@ -15,7 +15,6 @@ using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
-using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Drawings.Components;
@@ -24,7 +23,7 @@ using osuTK.Graphics;
namespace osu.Game.Tournament.Screens.Drawings
{
- public class DrawingsScreen : CompositeDrawable
+ public class DrawingsScreen : TournamentScreen
{
private const string results_filename = "drawings_results.txt";
@@ -128,21 +127,21 @@ namespace osu.Game.Tournament.Screens.Drawings
// Control panel container
new ControlPanel
{
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Begin random",
Action = teamsContainer.StartScrolling,
},
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Stop random",
Action = teamsContainer.StopScrolling,
},
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
@@ -150,7 +149,7 @@ namespace osu.Game.Tournament.Screens.Drawings
Action = reloadTeams
},
new ControlPanel.Spacer(),
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
@@ -195,7 +194,7 @@ namespace osu.Game.Tournament.Screens.Drawings
}
}
- writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run((Action)writeAction);
+ writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run(writeAction);
}
private void reloadTeams()
diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
index b036350879..7119533743 100644
--- a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
@@ -225,9 +225,7 @@ namespace osu.Game.Tournament.Screens.Editors
beatmapId.Value = Model.ID.ToString();
beatmapId.BindValueChanged(idString =>
{
- int parsed;
-
- int.TryParse(idString.NewValue, out parsed);
+ int.TryParse(idString.NewValue, out var parsed);
Model.ID = parsed;
@@ -266,12 +264,14 @@ namespace osu.Game.Tournament.Screens.Editors
drawableContainer.Clear();
if (Model.BeatmapInfo != null)
+ {
drawableContainer.Child = new TournamentBeatmapPanel(Model.BeatmapInfo, Model.Mods)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = 300
};
+ }
}
}
}
diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs
index a4479f3cfd..494dd73edd 100644
--- a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs
@@ -11,9 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
-using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
-using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
@@ -25,14 +23,14 @@ namespace osu.Game.Tournament.Screens.Editors
public class TeamEditorScreen : TournamentEditorScreen
{
[Resolved]
- private Framework.Game game { get; set; }
+ private TournamentGameBase game { get; set; }
protected override BindableList Storage => LadderInfo.Teams;
[BackgroundDependencyLoader]
private void load()
{
- ControlPanel.Add(new OsuButton
+ ControlPanel.Add(new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Add all countries",
@@ -199,6 +197,9 @@ namespace osu.Game.Tournament.Screens.Editors
[Resolved]
protected IAPIProvider API { get; private set; }
+ [Resolved]
+ private TournamentGameBase game { get; set; }
+
private readonly Bindable userId = new Bindable();
private readonly Container drawableContainer;
@@ -266,9 +267,7 @@ namespace osu.Game.Tournament.Screens.Editors
userId.Value = user.Id.ToString();
userId.BindValueChanged(idString =>
{
- long parsed;
-
- long.TryParse(idString.NewValue, out parsed);
+ long.TryParse(idString.NewValue, out var parsed);
user.Id = parsed;
@@ -281,25 +280,7 @@ namespace osu.Game.Tournament.Screens.Editors
return;
}
- var req = new GetUserRequest(user.Id);
-
- req.Success += res =>
- {
- // TODO: this should be done in a better way.
- user.Username = res.Username;
- user.Country = res.Country;
- user.Cover = res.Cover;
-
- updatePanel();
- };
-
- req.Failure += _ =>
- {
- user.Id = 1;
- updatePanel();
- };
-
- API.Queue(req);
+ game.PopulateUser(user, updatePanel, updatePanel);
}, true);
}
diff --git a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
index 50d3207345..32cf6bbcc8 100644
--- a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
@@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
-using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
using osuTK;
@@ -56,7 +55,7 @@ namespace osu.Game.Tournament.Screens.Editors
{
Children = new Drawable[]
{
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Add new",
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs
index 78455c8bb7..cc7903f2fa 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs
@@ -100,7 +100,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
var diff = Math.Max(score1.Value, score2.Value) - Math.Min(score1.Value, score2.Value);
losingBar.ResizeWidthTo(0, 400, Easing.OutQuint);
- winningBar.ResizeWidthTo(Math.Min(0.4f, (float)Math.Pow(diff / 1500000f, 0.5) / 2), 400, Easing.OutQuint);
+ winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint);
}
protected override void Update()
diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
index b9a74bfe16..6a3095d42d 100644
--- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
@@ -103,13 +103,13 @@ namespace osu.Game.Tournament.Screens.Gameplay
{
Children = new Drawable[]
{
- warmupButton = new OsuButton
+ warmupButton = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Toggle warmup",
Action = () => warmup.Toggle()
},
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Toggle chat",
diff --git a/osu.Game.Tournament/Screens/Ladder/Components/ProgressionPath.cs b/osu.Game.Tournament/Screens/Ladder/Components/ProgressionPath.cs
index 34e0dc770f..84a329085a 100644
--- a/osu.Game.Tournament/Screens/Ladder/Components/ProgressionPath.cs
+++ b/osu.Game.Tournament/Screens/Ladder/Components/ProgressionPath.cs
@@ -26,7 +26,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
{
base.LoadComplete();
- Vector2 getCenteredVector(Vector2 top, Vector2 bottom) => new Vector2(top.X, top.Y + (bottom.Y - top.Y) / 2);
+ static Vector2 getCenteredVector(Vector2 top, Vector2 bottom) => new Vector2(top.X, top.Y + (bottom.Y - top.Y) / 2);
var q1 = Source.ScreenSpaceDrawQuad;
var q2 = Destination.ScreenSpaceDrawQuad;
diff --git a/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs b/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs
index f613ce5f46..0c450a66b4 100644
--- a/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs
+++ b/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@@ -32,9 +33,9 @@ namespace osu.Game.Tournament.Screens.Ladder
protected override bool OnScroll(ScrollEvent e)
{
- var newScale = MathHelper.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
+ var newScale = Math.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
- this.MoveTo(target = target - e.MousePosition * (newScale - scale), 2000, Easing.OutQuint);
+ this.MoveTo(target -= e.MousePosition * (newScale - scale), 2000, Easing.OutQuint);
this.ScaleTo(scale = newScale, 2000, Easing.OutQuint);
return true;
diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
index 83a41a662f..66e68a0f37 100644
--- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
+++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs
@@ -81,8 +81,10 @@ namespace osu.Game.Tournament.Screens.Ladder
LadderInfo.Matches.ItemsRemoved += matches =>
{
foreach (var p in matches)
- foreach (var d in MatchesContainer.Where(d => d.Match == p))
- d.Expire();
+ {
+ foreach (var d in MatchesContainer.Where(d => d.Match == p))
+ d.Expire();
+ }
layout.Invalidate();
};
diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
index d32c0d6156..c3875716b8 100644
--- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
+++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
@@ -60,32 +60,32 @@ namespace osu.Game.Tournament.Screens.MapPool
{
Text = "Current Mode"
},
- buttonRedBan = new OsuButton
+ buttonRedBan = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Red Ban",
Action = () => setMode(TeamColour.Red, ChoiceType.Ban)
},
- buttonBlueBan = new OsuButton
+ buttonBlueBan = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Blue Ban",
Action = () => setMode(TeamColour.Blue, ChoiceType.Ban)
},
- buttonRedPick = new OsuButton
+ buttonRedPick = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Red Pick",
Action = () => setMode(TeamColour.Red, ChoiceType.Pick)
},
- buttonBluePick = new OsuButton
+ buttonBluePick = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Blue Pick",
Action = () => setMode(TeamColour.Blue, ChoiceType.Pick)
},
new ControlPanel.Spacer(),
- new OsuButton
+ new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Reset",
@@ -120,7 +120,7 @@ namespace osu.Game.Tournament.Screens.MapPool
pickColour = colour;
pickType = choiceType;
- Color4 setColour(bool active) => active ? Color4.White : Color4.Gray;
+ static Color4 setColour(bool active) => active ? Color4.White : Color4.Gray;
buttonRedBan.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Ban);
buttonBlueBan.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Ban);
@@ -196,7 +196,7 @@ namespace osu.Game.Tournament.Screens.MapPool
setNextMode();
- if (pickType == ChoiceType.Pick)
+ if (pickType == ChoiceType.Pick && currentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
{
scheduledChange?.Cancel();
scheduledChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
diff --git a/osu.Game.Tournament/Screens/SetupScreen.cs b/osu.Game.Tournament/Screens/SetupScreen.cs
index 091a837745..8e1481d87c 100644
--- a/osu.Game.Tournament/Screens/SetupScreen.cs
+++ b/osu.Game.Tournament/Screens/SetupScreen.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -10,6 +11,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API;
using osu.Game.Overlays;
+using osu.Game.Rulesets;
using osu.Game.Tournament.IPC;
using osuTK;
using osuTK.Graphics;
@@ -28,6 +30,9 @@ namespace osu.Game.Tournament.Screens
[Resolved]
private IAPIProvider api { get; set; }
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
+
[BackgroundDependencyLoader]
private void load()
{
@@ -85,11 +90,38 @@ namespace osu.Game.Tournament.Screens
Value = api?.LocalUser.Value.Username,
Failing = api?.IsLoggedIn != true,
Description = "In order to access the API and display metadata, a login is required."
- }
+ },
+ new LabelledDropdown
+ {
+ Label = "Ruleset",
+ Description = "Decides what stats are displayed and which ranks are retrieved for players",
+ Items = rulesets.AvailableRulesets,
+ Current = LadderInfo.Ruleset,
+ },
};
}
- private class ActionableInfo : LabelledComponent
+ public class LabelledDropdown : LabelledComponent, T>
+ {
+ public LabelledDropdown()
+ : base(true)
+ {
+ }
+
+ public IEnumerable Items
+ {
+ get => Component.Items;
+ set => Component.Items = value;
+ }
+
+ protected override OsuDropdown CreateComponent() => new OsuDropdown
+ {
+ RelativeSizeAxes = Axes.X,
+ Width = 0.5f,
+ };
+ }
+
+ private class ActionableInfo : LabelledDrawable
{
private OsuButton button;
diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
index c901a5c7ef..47c923ff30 100644
--- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
@@ -164,6 +164,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
if (team != null)
{
foreach (var p in team.Players)
+ {
players.Add(new OsuSpriteText
{
Text = p.Username,
@@ -172,6 +173,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft,
});
+ }
}
}
diff --git a/osu.Game.Tournament/Screens/TournamentScreen.cs b/osu.Game.Tournament/Screens/TournamentScreen.cs
index 9d58ca2240..0b5b3e728b 100644
--- a/osu.Game.Tournament/Screens/TournamentScreen.cs
+++ b/osu.Game.Tournament/Screens/TournamentScreen.cs
@@ -10,6 +10,8 @@ namespace osu.Game.Tournament.Screens
{
public abstract class TournamentScreen : CompositeDrawable
{
+ public const double FADE_DELAY = 200;
+
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
@@ -18,14 +20,8 @@ namespace osu.Game.Tournament.Screens
RelativeSizeAxes = Axes.Both;
}
- public override void Hide()
- {
- this.FadeOut(200);
- }
+ public override void Hide() => this.FadeOut(FADE_DELAY);
- public override void Show()
- {
- this.FadeIn(200);
- }
+ public override void Show() => this.FadeIn(FADE_DELAY);
}
}
diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs
index dbfa70704b..4d7abfe272 100644
--- a/osu.Game.Tournament/TournamentGameBase.cs
+++ b/osu.Game.Tournament/TournamentGameBase.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -11,22 +12,23 @@ using osu.Framework.Configuration;
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.Framework.Input;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
-using osu.Game.Graphics.UserInterface;
+using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
+using osu.Game.Users;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tournament
{
+ [Cached(typeof(TournamentGameBase))]
public abstract class TournamentGameBase : OsuGameBase
{
private const string bracket_filename = "bracket.json";
@@ -52,8 +54,8 @@ namespace osu.Game.Tournament
{
Resources.AddStore(new DllResourceStore(@"osu.Game.Tournament.dll"));
- Fonts.AddStore(new GlyphStore(Resources, @"Resources/Fonts/Aquatico-Regular"));
- Fonts.AddStore(new GlyphStore(Resources, @"Resources/Fonts/Aquatico-Light"));
+ AddFont(Resources, @"Resources/Fonts/Aquatico-Regular");
+ AddFont(Resources, @"Resources/Fonts/Aquatico-Light");
Textures.AddStore(new TextureLoaderStore(new ResourceStore(new StorageBackedResourceStore(storage))));
@@ -76,7 +78,7 @@ namespace osu.Game.Tournament
AddRange(new[]
{
- new OsuButton
+ new TourneyButton
{
Text = "Save Changes",
Width = 140,
@@ -102,7 +104,7 @@ namespace osu.Game.Tournament
Colour = Color4.Red,
RelativeSizeAxes = Axes.Both,
},
- new SpriteText
+ new OsuSpriteText
{
Text = "Please make the window wider",
Font = OsuFont.Default.With(weight: "bold"),
@@ -127,6 +129,11 @@ namespace osu.Game.Tournament
ladder = new LadderInfo();
}
+ if (ladder.Ruleset.Value == null)
+ ladder.Ruleset.Value = RulesetStore.AvailableRulesets.First();
+
+ Ruleset.BindTo(ladder.Ruleset);
+
dependencies.Cache(ladder);
bool addedInfo = false;
@@ -165,15 +172,17 @@ namespace osu.Game.Tournament
// link matches to rounds
foreach (var round in ladder.Rounds)
- foreach (var id in round.Matches)
{
- var found = ladder.Matches.FirstOrDefault(p => p.ID == id);
-
- if (found != null)
+ foreach (var id in round.Matches)
{
- found.Round.Value = round;
- if (round.StartDate.Value > found.Date.Value)
- found.Date.Value = round.StartDate.Value;
+ var found = ladder.Matches.FirstOrDefault(p => p.ID == id);
+
+ if (found != null)
+ {
+ found.Round.Value = round;
+ if (round.StartDate.Value > found.Date.Value)
+ found.Date.Value = round.StartDate.Value;
+ }
}
}
@@ -193,15 +202,14 @@ namespace osu.Game.Tournament
bool addedInfo = false;
foreach (var t in ladder.Teams)
- foreach (var p in t.Players)
- if (string.IsNullOrEmpty(p.Username))
+ {
+ foreach (var p in t.Players)
{
- var req = new GetUserRequest(p.Id);
- req.Perform(API);
- p.Username = req.Result.Username;
-
+ if (p.Username == null || p.Statistics == null)
+ PopulateUser(p);
addedInfo = true;
}
+ }
return addedInfo;
}
@@ -214,19 +222,46 @@ namespace osu.Game.Tournament
bool addedInfo = false;
foreach (var r in ladder.Rounds)
- foreach (var b in r.Beatmaps)
- if (b.BeatmapInfo == null)
+ {
+ foreach (var b in r.Beatmaps)
{
- var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
- req.Perform(API);
- b.BeatmapInfo = req.Result?.ToBeatmap(RulesetStore);
+ if (b.BeatmapInfo == null && b.ID > 0)
+ {
+ var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
+ API.Perform(req);
+ b.BeatmapInfo = req.Result?.ToBeatmap(RulesetStore);
- addedInfo = true;
+ addedInfo = true;
+ }
}
+ }
return addedInfo;
}
+ public void PopulateUser(User user, Action success = null, Action failure = null)
+ {
+ var req = new GetUserRequest(user.Id, Ruleset.Value);
+
+ req.Success += res =>
+ {
+ user.Username = res.Username;
+ user.Statistics = res.Statistics;
+ user.Country = res.Country;
+ user.Cover = res.Cover;
+
+ success?.Invoke();
+ };
+
+ req.Failure += _ =>
+ {
+ user.Id = 1;
+ failure?.Invoke();
+ };
+
+ API.Queue(req);
+ }
+
protected override void LoadComplete()
{
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display
diff --git a/osu.Game.Tournament/TournamentSceneManager.cs b/osu.Game.Tournament/TournamentSceneManager.cs
index 02ee1c8603..de3d685c31 100644
--- a/osu.Game.Tournament/TournamentSceneManager.cs
+++ b/osu.Game.Tournament/TournamentSceneManager.cs
@@ -8,7 +8,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform;
-using osu.Game.Graphics.UserInterface;
+using osu.Framework.Threading;
+using osu.Game.Graphics;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens;
@@ -36,6 +37,7 @@ namespace osu.Game.Tournament
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
private Container chatContainer;
+ private FillFlowContainer buttons;
public TournamentSceneManager()
{
@@ -101,68 +103,136 @@ namespace osu.Game.Tournament
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
- new FillFlowContainer
+ buttons = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
+ Spacing = new Vector2(2),
+ Padding = new MarginPadding(2),
Children = new Drawable[]
{
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Setup", Action = () => SetScreen(typeof(SetupScreen)) },
- new Container { RelativeSizeAxes = Axes.X, Height = 50 },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Team Editor", Action = () => SetScreen(typeof(TeamEditorScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Rounds Editor", Action = () => SetScreen(typeof(RoundEditorScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen)) },
- new Container { RelativeSizeAxes = Axes.X, Height = 50 },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => SetScreen(typeof(DrawingsScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => SetScreen(typeof(ShowcaseScreen)) },
- new Container { RelativeSizeAxes = Axes.X, Height = 50 },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => SetScreen(typeof(ScheduleScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => SetScreen(typeof(LadderScreen)) },
- new Container { RelativeSizeAxes = Axes.X, Height = 50 },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => SetScreen(typeof(TeamIntroScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => SetScreen(typeof(MapPoolScreen)) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => SetScreen(typeof(GameplayScreen)) },
- new Container { RelativeSizeAxes = Axes.X, Height = 50 },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Win", Action = () => SetScreen(typeof(TeamWinScreen)) },
+ new ScreenButton(typeof(SetupScreen)) { Text = "Setup", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(TeamEditorScreen)) { Text = "Team Editor", RequestSelection = SetScreen },
+ new ScreenButton(typeof(RoundEditorScreen)) { Text = "Rounds Editor", RequestSelection = SetScreen },
+ new ScreenButton(typeof(LadderEditorScreen)) { Text = "Bracket Editor", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(ScheduleScreen)) { Text = "Schedule", RequestSelection = SetScreen },
+ new ScreenButton(typeof(LadderScreen)) { Text = "Bracket", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(TeamIntroScreen)) { Text = "TeamIntro", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(MapPoolScreen)) { Text = "MapPool", RequestSelection = SetScreen },
+ new ScreenButton(typeof(GameplayScreen)) { Text = "Gameplay", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(TeamWinScreen)) { Text = "Win", RequestSelection = SetScreen },
+ new Separator(),
+ new ScreenButton(typeof(DrawingsScreen)) { Text = "Drawings", RequestSelection = SetScreen },
+ new ScreenButton(typeof(ShowcaseScreen)) { Text = "Showcase", RequestSelection = SetScreen },
}
},
},
},
};
+ foreach (var drawable in screens)
+ drawable.Hide();
+
SetScreen(typeof(SetupScreen));
}
+ private float depth;
+
+ private Drawable currentScreen;
+ private ScheduledDelegate scheduledHide;
+
public void SetScreen(Type screenType)
{
- var screen = screens.FirstOrDefault(s => s.GetType() == screenType);
- if (screen == null) return;
+ var target = screens.FirstOrDefault(s => s.GetType() == screenType);
- foreach (var s in screens.Children)
+ if (target == null || currentScreen == target) return;
+
+ if (scheduledHide?.Completed == false)
{
- if (s == screen)
- {
- s.Show();
- if (s is IProvideVideo)
- video.FadeOut(200);
- else
- video.Show();
- }
- else
- s.Hide();
+ scheduledHide.RunTask();
+ scheduledHide.Cancel(); // see https://github.com/ppy/osu-framework/issues/2967
+ scheduledHide = null;
}
- switch (screen)
+ var lastScreen = currentScreen;
+ currentScreen = target;
+
+ if (currentScreen is IProvideVideo)
+ {
+ video.FadeOut(200);
+
+ // delay the hide to avoid a double-fade transition.
+ scheduledHide = Scheduler.AddDelayed(() => lastScreen?.Hide(), TournamentScreen.FADE_DELAY);
+ }
+ else
+ {
+ lastScreen?.Hide();
+ video.Show();
+ }
+
+ screens.ChangeChildDepth(currentScreen, depth--);
+ currentScreen.Show();
+
+ switch (currentScreen)
{
case GameplayScreen _:
case MapPoolScreen _:
- chatContainer.FadeIn(100);
+ chatContainer.FadeIn(TournamentScreen.FADE_DELAY);
break;
default:
- chatContainer.FadeOut(100);
+ chatContainer.FadeOut(TournamentScreen.FADE_DELAY);
break;
}
+
+ foreach (var s in buttons.OfType())
+ s.IsSelected = screenType == s.Type;
+ }
+
+ private class Separator : CompositeDrawable
+ {
+ public Separator()
+ {
+ RelativeSizeAxes = Axes.X;
+ Height = 20;
+ }
+ }
+
+ private class ScreenButton : TourneyButton
+ {
+ public readonly Type Type;
+
+ public ScreenButton(Type type)
+ {
+ Type = type;
+ BackgroundColour = OsuColour.Gray(0.2f);
+ Action = () => RequestSelection(type);
+
+ RelativeSizeAxes = Axes.X;
+ }
+
+ private bool isSelected;
+
+ public Action RequestSelection;
+
+ public bool IsSelected
+ {
+ get => isSelected;
+ set
+ {
+ if (value == isSelected)
+ return;
+
+ isSelected = value;
+ BackgroundColour = isSelected ? Color4.SkyBlue : OsuColour.Gray(0.2f);
+ SpriteText.Colour = isSelected ? Color4.Black : Color4.White;
+ }
+ }
}
}
}
diff --git a/osu.Game.Tournament/TourneyButton.cs b/osu.Game.Tournament/TourneyButton.cs
new file mode 100644
index 0000000000..12872d3197
--- /dev/null
+++ b/osu.Game.Tournament/TourneyButton.cs
@@ -0,0 +1,15 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Tournament
+{
+ public class TourneyButton : OsuButton
+ {
+ public TourneyButton()
+ : base(null)
+ {
+ }
+ }
+}
diff --git a/osu.Game.Tournament/osu.Game.Tournament.csproj b/osu.Game.Tournament/osu.Game.Tournament.csproj
index bddaff0a80..9cce40c9d3 100644
--- a/osu.Game.Tournament/osu.Game.Tournament.csproj
+++ b/osu.Game.Tournament/osu.Game.Tournament.csproj
@@ -1,9 +1,7 @@
-
- netstandard2.0
+ netstandard2.1
Library
- AnyCPU
true
tools for tournaments.
@@ -11,6 +9,6 @@
-
+
\ No newline at end of file
diff --git a/osu.Game.props b/osu.Game.props
deleted file mode 100644
index 1a3c0aec3e..0000000000
--- a/osu.Game.props
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- 7.2
-
-
- ..\app.manifest
-
-
-
- osu.licenseheader
-
-
-
-
-
-
- ppy Pty Ltd
- Copyright (c) 2019 ppy Pty Ltd
-
- NU1701
-
-
\ No newline at end of file
diff --git a/osu.Game/Audio/PreviewTrack.cs b/osu.Game/Audio/PreviewTrack.cs
index 22ce7d4711..5df656e1e0 100644
--- a/osu.Game/Audio/PreviewTrack.cs
+++ b/osu.Game/Audio/PreviewTrack.cs
@@ -9,48 +9,52 @@ using osu.Framework.Threading;
namespace osu.Game.Audio
{
+ [LongRunningLoad]
public abstract class PreviewTrack : Component
{
///
/// Invoked when this has stopped playing.
+ /// Not invoked in a thread-safe context.
///
public event Action Stopped;
///
/// Invoked when this has started playing.
+ /// Not invoked in a thread-safe context.
///
public event Action Started;
- private Track track;
+ protected Track Track { get; private set; }
+
private bool hasStarted;
[BackgroundDependencyLoader]
private void load()
{
- track = GetTrack();
- if (track != null)
- track.Completed += () => Schedule(Stop);
+ Track = GetTrack();
+ if (Track != null)
+ Track.Completed += Stop;
}
///
/// Length of the track.
///
- public double Length => track?.Length ?? 0;
+ public double Length => Track?.Length ?? 0;
///
/// The current track time.
///
- public double CurrentTime => track?.CurrentTime ?? 0;
+ public double CurrentTime => Track?.CurrentTime ?? 0;
///
/// Whether the track is loaded.
///
- public bool TrackLoaded => track?.IsLoaded ?? false;
+ public bool TrackLoaded => Track?.IsLoaded ?? false;
///
/// Whether the track is playing.
///
- public bool IsRunning => track?.IsRunning ?? false;
+ public bool IsRunning => Track?.IsRunning ?? false;
private ScheduledDelegate startDelegate;
@@ -60,7 +64,7 @@ namespace osu.Game.Audio
/// Whether the track is started or already playing.
public bool Start()
{
- if (track == null)
+ if (Track == null)
return false;
startDelegate = Schedule(() =>
@@ -70,7 +74,7 @@ namespace osu.Game.Audio
hasStarted = true;
- track.Restart();
+ Track.Restart();
Started?.Invoke();
});
@@ -84,7 +88,7 @@ namespace osu.Game.Audio
{
startDelegate?.Cancel();
- if (track == null)
+ if (Track == null)
return;
if (!hasStarted)
@@ -92,7 +96,8 @@ namespace osu.Game.Audio
hasStarted = false;
- track.Stop();
+ Track.Stop();
+
Stopped?.Invoke();
}
diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs
index e12c46ef16..6f0b62543d 100644
--- a/osu.Game/Audio/PreviewTrackManager.cs
+++ b/osu.Game/Audio/PreviewTrackManager.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Audio
private AudioManager audio;
private PreviewTrackStore trackStore;
- private TrackManagerPreviewTrack current;
+ protected TrackManagerPreviewTrack CurrentTrack;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
@@ -46,18 +46,21 @@ namespace osu.Game.Audio
{
var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
- track.Started += () =>
+ track.Started += () => Schedule(() =>
{
- current?.Stop();
- current = track;
+ CurrentTrack?.Stop();
+ CurrentTrack = track;
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
- };
+ });
- track.Stopped += () =>
+ track.Stopped += () => Schedule(() =>
{
- current = null;
+ if (CurrentTrack != track)
+ return;
+
+ CurrentTrack = null;
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
- };
+ });
return track;
}
@@ -73,11 +76,11 @@ namespace osu.Game.Audio
/// The which may be the owner of the .
public void StopAnyPlaying(IPreviewTrackOwner source)
{
- if (current == null || current.Owner != source)
+ if (CurrentTrack == null || CurrentTrack.Owner != source)
return;
- current.Stop();
- current = null;
+ CurrentTrack.Stop();
+ // CurrentTrack should not be set to null here as it will result in incorrect handling in the track.Stopped callback above.
}
///
@@ -85,7 +88,7 @@ namespace osu.Game.Audio
///
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore);
- protected class TrackManagerPreviewTrack : PreviewTrack
+ public class TrackManagerPreviewTrack : PreviewTrack
{
public IPreviewTrackOwner Owner { get; private set; }
diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs
index 8727431e0e..c56fec67aa 100644
--- a/osu.Game/Beatmaps/BeatmapDifficulty.cs
+++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs
@@ -56,10 +56,22 @@ namespace osu.Game.Beatmaps
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
///
/// The difficulty value to be mapped.
- /// The values that define the two linear ranges.
- /// Minimum of the resulting range which will be achieved by a difficulty value of 0.
- /// Midpoint of the resulting range which will be achieved by a difficulty value of 5.
- /// Maximum of the resulting range which will be achieved by a difficulty value of 10.
+ /// The values that define the two linear ranges.
+ ///
+ /// -
+ /// od0
+ /// Minimum of the resulting range which will be achieved by a difficulty value of 0.
+ ///
+ /// -
+ /// od5
+ /// Midpoint of the resulting range which will be achieved by a difficulty value of 5.
+ ///
+ /// -
+ /// od10
+ /// Maximum of the resulting range which will be achieved by a difficulty value of 10.
+ ///
+ ///
+ ///
/// Value to which the difficulty value maps in the specified range.
public static double DifficultyRange(double difficulty, (double od0, double od5, double od10) range)
=> DifficultyRange(difficulty, range.od0, range.od5, range.od10);
diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs
index 198046df4f..6e82c465dc 100644
--- a/osu.Game/Beatmaps/BeatmapInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapInfo.cs
@@ -76,7 +76,7 @@ namespace osu.Game.Beatmaps
public string MD5Hash { get; set; }
// General
- public int AudioLeadIn { get; set; }
+ public double AudioLeadIn { get; set; }
public bool Countdown { get; set; } = true;
public float StackLeniency { get; set; } = 0.7f;
public bool SpecialStyle { get; set; }
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index dd2044b4bc..a2e750cac5 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -25,7 +25,7 @@ using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Rulesets;
-using osu.Game.Rulesets.Objects.Types;
+using osu.Game.Rulesets.Objects;
namespace osu.Game.Beatmaps
{
@@ -129,9 +129,12 @@ namespace osu.Game.Beatmaps
{
var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineBeatmapID.HasValue).Select(b => b.OnlineBeatmapID).ToList();
+ LogForModel(beatmapSet, "Validating online IDs...");
+
// ensure all IDs are unique
if (beatmapIds.GroupBy(b => b).Any(g => g.Count() > 1))
{
+ LogForModel(beatmapSet, "Found non-unique IDs, resetting...");
resetIds();
return;
}
@@ -144,8 +147,12 @@ namespace osu.Game.Beatmaps
// reset the import ids (to force a re-fetch) *unless* they match the candidate CheckForExisting set.
// we can ignore the case where the new ids are contained by the CheckForExisting set as it will either be used (import skipped) or deleted.
var existing = CheckForExisting(beatmapSet);
+
if (existing == null || existingBeatmaps.Any(b => !existing.Beatmaps.Contains(b)))
+ {
+ LogForModel(beatmapSet, "Found existing import with IDs already, resetting...");
resetIds();
+ }
}
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineBeatmapID = null);
@@ -296,8 +303,13 @@ namespace osu.Game.Beatmaps
var decoder = Decoder.GetDecoder(sr);
IBeatmap beatmap = decoder.Decode(sr);
+ string hash = ms.ComputeSHA2Hash();
+
+ if (beatmapInfos.Any(b => b.Hash == hash))
+ continue;
+
beatmap.BeatmapInfo.Path = file.Filename;
- beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
+ beatmap.BeatmapInfo.Hash = hash;
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
var ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
@@ -322,7 +334,8 @@ namespace osu.Game.Beatmaps
var lastObject = b.HitObjects.Last();
- double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;
+ //TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list).
+ double endTime = lastObject.GetEndTime();
double startTime = b.HitObjects.First().StartTime;
return endTime - startTime;
@@ -380,20 +393,32 @@ namespace osu.Game.Beatmaps
var req = new GetBeatmapRequest(beatmap);
- req.Success += res =>
+ req.Failure += fail;
+
+ try
{
- LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
+ // intentionally blocking to limit web request concurrency
+ api.Perform(req);
+
+ var res = req.Result;
beatmap.Status = res.Status;
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
- };
- req.Failure += e => { LogForModel(set, $"Online retrieval failed for {beatmap} ({e.Message})"); };
+ LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
+ }
+ catch (Exception e)
+ {
+ fail(e);
+ }
- // intentionally blocking to limit web request concurrency
- req.Perform(api);
+ void fail(Exception e)
+ {
+ beatmap.OnlineBeatmapID = null;
+ LogForModel(set, $"Online retrieval failed for {beatmap} ({e.Message})");
+ }
}
}
}
diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
index b879b92f01..4924842e81 100644
--- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
@@ -84,7 +84,7 @@ namespace osu.Game.Beatmaps
{
try
{
- return (trackStore ?? (trackStore = AudioManager.GetTrackStore(store))).Get(getPathForFile(Metadata.AudioFile));
+ return (trackStore ??= AudioManager.GetTrackStore(store)).Get(getPathForFile(Metadata.AudioFile));
}
catch
{
diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs
index 03bc7c7312..a8b83dca38 100644
--- a/osu.Game/Beatmaps/BeatmapSetInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs
@@ -63,6 +63,21 @@ namespace osu.Game.Beatmaps
public bool Protected { get; set; }
- public bool Equals(BeatmapSetInfo other) => OnlineBeatmapSetID == other?.OnlineBeatmapSetID;
+ public bool Equals(BeatmapSetInfo other)
+ {
+ if (other == null)
+ return false;
+
+ if (ID != 0 && other.ID != 0)
+ return ID == other.ID;
+
+ if (OnlineBeatmapSetID.HasValue && other.OnlineBeatmapSetID.HasValue)
+ return OnlineBeatmapSetID == other.OnlineBeatmapSetID;
+
+ if (!string.IsNullOrEmpty(Hash) && !string.IsNullOrEmpty(other.Hash))
+ return Hash == other.Hash;
+
+ return ReferenceEquals(this, other);
+ }
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
index abe7e5e803..39a0e6f6d4 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
@@ -1,25 +1,30 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
namespace osu.Game.Beatmaps.ControlPoints
{
- public class ControlPoint : IComparable, IEquatable
+ public abstract class ControlPoint : IComparable, IEquatable
{
///
/// The time at which the control point takes effect.
///
- public double Time;
+ public double Time => controlPointGroup?.Time ?? 0;
- ///
- /// Whether this timing point was generated internally, as opposed to parsed from the underlying beatmap.
- ///
- internal bool AutoGenerated;
+ private ControlPointGroup controlPointGroup;
+
+ public void AttachGroup(ControlPointGroup pointGroup) => controlPointGroup = pointGroup;
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
- public bool Equals(ControlPoint other)
- => Time.Equals(other?.Time);
+ ///
+ /// Whether this control point is equivalent to another, ignoring time.
+ ///
+ /// Another control point to compare with.
+ /// Whether equivalent.
+ public abstract bool EquivalentTo(ControlPoint other);
+
+ public bool Equals(ControlPoint other) => Time == other?.Time && EquivalentTo(other);
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointGroup.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointGroup.cs
new file mode 100644
index 0000000000..cb73ce884e
--- /dev/null
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPointGroup.cs
@@ -0,0 +1,50 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Linq;
+using osu.Framework.Bindables;
+
+namespace osu.Game.Beatmaps.ControlPoints
+{
+ public class ControlPointGroup : IComparable
+ {
+ public event Action ItemAdded;
+ public event Action ItemRemoved;
+
+ ///
+ /// The time at which the control point takes effect.
+ ///
+ public double Time { get; }
+
+ public IBindableList ControlPoints => controlPoints;
+
+ private readonly BindableList controlPoints = new BindableList();
+
+ public ControlPointGroup(double time)
+ {
+ Time = time;
+ }
+
+ public int CompareTo(ControlPointGroup other) => Time.CompareTo(other.Time);
+
+ public void Add(ControlPoint point)
+ {
+ var existing = controlPoints.FirstOrDefault(p => p.GetType() == point.GetType());
+
+ if (existing != null)
+ Remove(existing);
+
+ point.AttachGroup(this);
+
+ controlPoints.Add(point);
+ ItemAdded?.Invoke(point);
+ }
+
+ public void Remove(ControlPoint point)
+ {
+ controlPoints.Remove(point);
+ ItemRemoved?.Invoke(point);
+ }
+ }
+}
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
index 855084ad02..ce2783004c 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
+using osu.Framework.Bindables;
using osu.Framework.Lists;
namespace osu.Game.Beatmaps.ControlPoints
@@ -12,57 +13,78 @@ namespace osu.Game.Beatmaps.ControlPoints
[Serializable]
public class ControlPointInfo
{
+ ///
+ /// All control points grouped by time.
+ ///
+ [JsonProperty]
+ public IBindableList Groups => groups;
+
+ private readonly BindableList groups = new BindableList();
+
///
/// All timing points.
///
[JsonProperty]
- public SortedList TimingPoints { get; private set; } = new SortedList(Comparer.Default);
+ public IReadOnlyList TimingPoints => timingPoints;
+
+ private readonly SortedList timingPoints = new SortedList(Comparer.Default);
///
/// All difficulty points.
///
[JsonProperty]
- public SortedList DifficultyPoints { get; private set; } = new SortedList(Comparer.Default);
+ public IReadOnlyList DifficultyPoints => difficultyPoints;
+
+ private readonly SortedList difficultyPoints = new SortedList(Comparer.Default);
///
/// All sound points.
///
[JsonProperty]
- public SortedList SamplePoints { get; private set; } = new SortedList(Comparer.Default);
+ public IReadOnlyList SamplePoints => samplePoints;
+
+ private readonly SortedList samplePoints = new SortedList(Comparer.Default);
///
/// All effect points.
///
[JsonProperty]
- public SortedList EffectPoints { get; private set; } = new SortedList(Comparer.Default);
+ public IReadOnlyList EffectPoints => effectPoints;
+
+ private readonly SortedList effectPoints = new SortedList(Comparer.Default);
+
+ ///
+ /// All control points, of all types.
+ ///
+ public IEnumerable AllControlPoints => Groups.SelectMany(g => g.ControlPoints).ToArray();
///
/// Finds the difficulty control point that is active at .
///
/// The time to find the difficulty control point at.
/// The difficulty control point.
- public DifficultyControlPoint DifficultyPointAt(double time) => binarySearch(DifficultyPoints, time);
+ public DifficultyControlPoint DifficultyPointAt(double time) => binarySearchWithFallback(DifficultyPoints, time);
///
/// Finds the effect control point that is active at .
///
/// The time to find the effect control point at.
/// The effect control point.
- public EffectControlPoint EffectPointAt(double time) => binarySearch(EffectPoints, time);
+ public EffectControlPoint EffectPointAt(double time) => binarySearchWithFallback(EffectPoints, time);
///
/// Finds the sound control point that is active at .
///
/// The time to find the sound control point at.
/// The sound control point.
- public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : null);
+ public SampleControlPoint SamplePointAt(double time) => binarySearchWithFallback(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : null);
///
/// Finds the timing control point that is active at .
///
/// The time to find the timing control point at.
/// The timing control point.
- public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : null);
+ public TimingControlPoint TimingPointAt(double time) => binarySearchWithFallback(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : null);
///
/// Finds the maximum BPM represented by any timing control point.
@@ -85,24 +107,93 @@ namespace osu.Game.Beatmaps.ControlPoints
public double BPMMode =>
60000 / (TimingPoints.GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).FirstOrDefault()?.FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
+ ///
+ /// Remove all s and return to a pristine state.
+ ///
+ public void Clear()
+ {
+ groups.Clear();
+ timingPoints.Clear();
+ difficultyPoints.Clear();
+ samplePoints.Clear();
+ effectPoints.Clear();
+ }
+
+ ///
+ /// Add a new . Note that the provided control point may not be added if the correct state is already present at the provided time.
+ ///
+ /// The time at which the control point should be added.
+ /// The control point to add.
+ /// Whether the control point was added.
+ public bool Add(double time, ControlPoint controlPoint)
+ {
+ if (checkAlreadyExisting(time, controlPoint))
+ return false;
+
+ GroupAt(time, true).Add(controlPoint);
+ return true;
+ }
+
+ public ControlPointGroup GroupAt(double time, bool addIfNotExisting = false)
+ {
+ var newGroup = new ControlPointGroup(time);
+
+ int i = groups.BinarySearch(newGroup);
+
+ if (i >= 0)
+ return groups[i];
+
+ if (addIfNotExisting)
+ {
+ newGroup.ItemAdded += groupItemAdded;
+ newGroup.ItemRemoved += groupItemRemoved;
+
+ groups.Insert(~i, newGroup);
+ return newGroup;
+ }
+
+ return null;
+ }
+
+ public void RemoveGroup(ControlPointGroup group)
+ {
+ group.ItemAdded -= groupItemAdded;
+ group.ItemRemoved -= groupItemRemoved;
+
+ groups.Remove(group);
+ }
+
///
/// Binary searches one of the control point lists to find the active control point at .
+ /// Includes logic for returning a specific point when no matching point is found.
///
/// The list to search.
/// The time to find the control point at.
/// The control point to use when is before any control points. If null, a new control point will be constructed.
- /// The active control point at .
- private T binarySearch(SortedList list, double time, T prePoint = null)
+ /// The active control point at , or a fallback if none found.
+ private T binarySearchWithFallback(IReadOnlyList list, double time, T prePoint = null)
where T : ControlPoint, new()
+ {
+ return binarySearch(list, time) ?? prePoint ?? new T();
+ }
+
+ ///
+ /// Binary searches one of the control point lists to find the active control point at .
+ ///
+ /// The list to search.
+ /// The time to find the control point at.
+ /// The active control point at .
+ private T binarySearch(IReadOnlyList list, double time)
+ where T : ControlPoint
{
if (list == null)
throw new ArgumentNullException(nameof(list));
if (list.Count == 0)
- return new T();
+ return null;
if (time < list[0].Time)
- return prePoint ?? new T();
+ return null;
if (time >= list[list.Count - 1].Time)
return list[list.Count - 1];
@@ -125,5 +216,82 @@ namespace osu.Game.Beatmaps.ControlPoints
// l will be the first control point with Time > time, but we want the one before it
return list[l - 1];
}
+
+ ///
+ /// Check whether should be added.
+ ///
+ /// The time to find the timing control point at.
+ /// A point to be added.
+ /// Whether the new point should be added.
+ private bool checkAlreadyExisting(double time, ControlPoint newPoint)
+ {
+ ControlPoint existing = null;
+
+ switch (newPoint)
+ {
+ case TimingControlPoint _:
+ // Timing points are a special case and need to be added regardless of fallback availability.
+ existing = binarySearch(TimingPoints, time);
+ break;
+
+ case EffectControlPoint _:
+ existing = EffectPointAt(time);
+ break;
+
+ case SampleControlPoint _:
+ existing = SamplePointAt(time);
+ break;
+
+ case DifficultyControlPoint _:
+ existing = DifficultyPointAt(time);
+ break;
+ }
+
+ return existing?.EquivalentTo(newPoint) == true;
+ }
+
+ private void groupItemAdded(ControlPoint controlPoint)
+ {
+ switch (controlPoint)
+ {
+ case TimingControlPoint typed:
+ timingPoints.Add(typed);
+ break;
+
+ case EffectControlPoint typed:
+ effectPoints.Add(typed);
+ break;
+
+ case SampleControlPoint typed:
+ samplePoints.Add(typed);
+ break;
+
+ case DifficultyControlPoint typed:
+ difficultyPoints.Add(typed);
+ break;
+ }
+ }
+
+ private void groupItemRemoved(ControlPoint controlPoint)
+ {
+ switch (controlPoint)
+ {
+ case TimingControlPoint typed:
+ timingPoints.Remove(typed);
+ break;
+
+ case EffectControlPoint typed:
+ effectPoints.Remove(typed);
+ break;
+
+ case SampleControlPoint typed:
+ samplePoints.Remove(typed);
+ break;
+
+ case DifficultyControlPoint typed:
+ difficultyPoints.Remove(typed);
+ break;
+ }
+ }
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
index a3e3121575..8b21098a51 100644
--- a/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
@@ -1,26 +1,33 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
-using osuTK;
+using osu.Framework.Bindables;
namespace osu.Game.Beatmaps.ControlPoints
{
- public class DifficultyControlPoint : ControlPoint, IEquatable
+ public class DifficultyControlPoint : ControlPoint
{
+ ///
+ /// The speed multiplier at this control point.
+ ///
+ public readonly BindableDouble SpeedMultiplierBindable = new BindableDouble(1)
+ {
+ Precision = 0.1,
+ Default = 1,
+ MinValue = 0.1,
+ MaxValue = 10
+ };
+
///
/// The speed multiplier at this control point.
///
public double SpeedMultiplier
{
- get => speedMultiplier;
- set => speedMultiplier = MathHelper.Clamp(value, 0.1, 10);
+ get => SpeedMultiplierBindable.Value;
+ set => SpeedMultiplierBindable.Value = value;
}
- private double speedMultiplier = 1;
-
- public bool Equals(DifficultyControlPoint other)
- => base.Equals(other)
- && SpeedMultiplier.Equals(other?.SpeedMultiplier);
+ public override bool EquivalentTo(ControlPoint other) =>
+ other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
index 354d86dc13..369b93ff3d 100644
--- a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
@@ -1,24 +1,42 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
+using osu.Framework.Bindables;
namespace osu.Game.Beatmaps.ControlPoints
{
- public class EffectControlPoint : ControlPoint, IEquatable
+ public class EffectControlPoint : ControlPoint
{
///
- /// Whether this control point enables Kiai mode.
+ /// Whether the first bar line of this control point is ignored.
///
- public bool KiaiMode;
+ public readonly BindableBool OmitFirstBarLineBindable = new BindableBool();
///
/// Whether the first bar line of this control point is ignored.
///
- public bool OmitFirstBarLine;
+ public bool OmitFirstBarLine
+ {
+ get => OmitFirstBarLineBindable.Value;
+ set => OmitFirstBarLineBindable.Value = value;
+ }
- public bool Equals(EffectControlPoint other)
- => base.Equals(other)
- && KiaiMode == other?.KiaiMode && OmitFirstBarLine == other.OmitFirstBarLine;
+ ///
+ /// Whether this control point enables Kiai mode.
+ ///
+ public readonly BindableBool KiaiModeBindable = new BindableBool();
+
+ ///
+ /// Whether this control point enables Kiai mode.
+ ///
+ public bool KiaiMode
+ {
+ get => KiaiModeBindable.Value;
+ set => KiaiModeBindable.Value = value;
+ }
+
+ public override bool EquivalentTo(ControlPoint other) =>
+ other is EffectControlPoint otherTyped &&
+ KiaiMode == otherTyped.KiaiMode && OmitFirstBarLine == otherTyped.OmitFirstBarLine;
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
index 7bc7a9056d..42865c686c 100644
--- a/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
@@ -1,24 +1,47 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
+using osu.Framework.Bindables;
using osu.Game.Audio;
namespace osu.Game.Beatmaps.ControlPoints
{
- public class SampleControlPoint : ControlPoint, IEquatable
+ public class SampleControlPoint : ControlPoint
{
public const string DEFAULT_BANK = "normal";
///
/// The default sample bank at this control point.
///
- public string SampleBank = DEFAULT_BANK;
+ public readonly Bindable SampleBankBindable = new Bindable(DEFAULT_BANK) { Default = DEFAULT_BANK };
+
+ ///
+ /// The speed multiplier at this control point.
+ ///
+ public string SampleBank
+ {
+ get => SampleBankBindable.Value;
+ set => SampleBankBindable.Value = value;
+ }
+
+ ///
+ /// The default sample bank at this control point.
+ ///
+ public readonly BindableInt SampleVolumeBindable = new BindableInt(100)
+ {
+ MinValue = 0,
+ MaxValue = 100,
+ Default = 100
+ };
///
/// The default sample volume at this control point.
///
- public int SampleVolume = 100;
+ public int SampleVolume
+ {
+ get => SampleVolumeBindable.Value;
+ set => SampleVolumeBindable.Value = value;
+ }
///
/// Create a SampleInfo based on the sample settings in this control point.
@@ -45,8 +68,8 @@ namespace osu.Game.Beatmaps.ControlPoints
return newSampleInfo;
}
- public bool Equals(SampleControlPoint other)
- => base.Equals(other)
- && string.Equals(SampleBank, other?.SampleBank) && SampleVolume == other?.SampleVolume;
+ public override bool EquivalentTo(ControlPoint other) =>
+ other is SampleControlPoint otherTyped &&
+ string.Equals(SampleBank, otherTyped.SampleBank) && SampleVolume == otherTyped.SampleVolume;
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
index ccb8a92b3a..51b3377394 100644
--- a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
@@ -1,34 +1,55 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
-using osuTK;
+using osu.Framework.Bindables;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Beatmaps.ControlPoints
{
- public class TimingControlPoint : ControlPoint, IEquatable
+ public class TimingControlPoint : ControlPoint
{
///
/// The time signature at this control point.
///
- public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple;
+ public readonly Bindable TimeSignatureBindable = new Bindable(TimeSignatures.SimpleQuadruple) { Default = TimeSignatures.SimpleQuadruple };
+
+ ///
+ /// The time signature at this control point.
+ ///
+ public TimeSignatures TimeSignature
+ {
+ get => TimeSignatureBindable.Value;
+ set => TimeSignatureBindable.Value = value;
+ }
public const double DEFAULT_BEAT_LENGTH = 1000;
///
/// The beat length at this control point.
///
- public virtual double BeatLength
+ public readonly BindableDouble BeatLengthBindable = new BindableDouble(DEFAULT_BEAT_LENGTH)
{
- get => beatLength;
- set => beatLength = MathHelper.Clamp(value, 6, 60000);
+ Default = DEFAULT_BEAT_LENGTH,
+ MinValue = 6,
+ MaxValue = 60000
+ };
+
+ ///
+ /// The beat length at this control point.
+ ///
+ public double BeatLength
+ {
+ get => BeatLengthBindable.Value;
+ set => BeatLengthBindable.Value = value;
}
- private double beatLength = DEFAULT_BEAT_LENGTH;
+ ///
+ /// The BPM at this control point.
+ ///
+ public double BPM => 60000 / BeatLength;
- public bool Equals(TimingControlPoint other)
- => base.Equals(other)
- && TimeSignature == other?.TimeSignature && beatLength.Equals(other.beatLength);
+ public override bool EquivalentTo(ControlPoint other) =>
+ other is TimingControlPoint otherTyped
+ && TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
}
}
diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs
index d0db7765c2..5245bc319d 100644
--- a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs
+++ b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Drawables
{
+ [LongRunningLoad]
public class BeatmapSetCover : Sprite
{
private readonly BeatmapSetInfo set;
diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
index 8014631eca..7bd40af512 100644
--- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
+++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs
@@ -168,7 +168,7 @@ namespace osu.Game.Beatmaps.Drawables
difficultyName.Text = beatmap.Version;
starRating.Text = $"{beatmap.StarDifficulty:0.##}";
- difficultyFlow.Colour = colours.ForDifficultyRating(beatmap.DifficultyRating);
+ difficultyFlow.Colour = colours.ForDifficultyRating(beatmap.DifficultyRating, true);
return true;
}
diff --git a/osu.Game/Beatmaps/Formats/Decoder.cs b/osu.Game/Beatmaps/Formats/Decoder.cs
index 40c329eb7e..45122f6312 100644
--- a/osu.Game/Beatmaps/Formats/Decoder.cs
+++ b/osu.Game/Beatmaps/Formats/Decoder.cs
@@ -93,7 +93,7 @@ namespace osu.Game.Beatmaps.Formats
///
/// Registers a fallback decoder instantiation function.
/// The fallback will be returned if the first non-empty line of the decoded stream does not match any known magic.
- /// Calling this method will overwrite any existing global fallback registration for type - use with caution.
+ /// Calling this method will overwrite any existing global fallback registration for type - use with caution.
///
/// Type of object being decoded.
/// A function that constructs the fallback.
diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
index 786b7611b5..838b1c2f07 100644
--- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using osu.Framework.IO.File;
@@ -50,6 +51,8 @@ namespace osu.Game.Beatmaps.Formats
base.ParseStreamInto(stream, beatmap);
+ flushPendingPoints();
+
// Objects may be out of order *only* if a user has manually edited an .osu file.
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
@@ -290,9 +293,7 @@ namespace osu.Game.Beatmaps.Formats
{
string[] split = line.Split(',');
- EventType type;
-
- if (!Enum.TryParse(split[0], out type))
+ if (!Enum.TryParse(split[0], out EventType type))
throw new InvalidDataException($@"Unknown event type: {split[0]}");
switch (type)
@@ -369,104 +370,64 @@ namespace osu.Game.Beatmaps.Formats
if (timingChange)
{
var controlPoint = CreateTimingControlPoint();
- controlPoint.Time = time;
+
controlPoint.BeatLength = beatLength;
controlPoint.TimeSignature = timeSignature;
- handleTimingControlPoint(controlPoint);
+ addControlPoint(time, controlPoint, true);
}
- handleDifficultyControlPoint(new DifficultyControlPoint
+ addControlPoint(time, new LegacyDifficultyControlPoint
{
- Time = time,
SpeedMultiplier = speedMultiplier,
- AutoGenerated = timingChange
- });
+ }, timingChange);
- handleEffectControlPoint(new EffectControlPoint
+ addControlPoint(time, new EffectControlPoint
{
- Time = time,
KiaiMode = kiaiMode,
OmitFirstBarLine = omitFirstBarSignature,
- AutoGenerated = timingChange
- });
+ }, timingChange);
- handleSampleControlPoint(new LegacySampleControlPoint
+ addControlPoint(time, new LegacySampleControlPoint
{
- Time = time,
SampleBank = stringSampleSet,
SampleVolume = sampleVolume,
CustomSampleBank = customSampleBank,
- AutoGenerated = timingChange
- });
+ }, timingChange);
+
+ // To handle the scenario where a non-timing line shares the same time value as a subsequent timing line but
+ // appears earlier in the file, we buffer non-timing control points and rewrite them *after* control points from the timing line
+ // with the same time value (allowing them to overwrite as necessary).
+ //
+ // The expected outcome is that we prefer the non-timing line's adjustments over the timing line's adjustments when time is equal.
+ if (timingChange)
+ flushPendingPoints();
}
- private void handleTimingControlPoint(TimingControlPoint newPoint)
+ private readonly List pendingControlPoints = new List();
+ private double pendingControlPointsTime;
+
+ private void addControlPoint(double time, ControlPoint point, bool timingChange)
{
- var existing = beatmap.ControlPointInfo.TimingPointAt(newPoint.Time);
+ if (time != pendingControlPointsTime)
+ flushPendingPoints();
- if (existing.Time == newPoint.Time)
+ if (timingChange)
{
- // autogenerated points should not replace non-autogenerated.
- // this allows for incorrectly ordered timing points to still be correctly handled.
- if (newPoint.AutoGenerated && !existing.AutoGenerated)
- return;
-
- beatmap.ControlPointInfo.TimingPoints.Remove(existing);
+ beatmap.ControlPointInfo.Add(time, point);
+ return;
}
- beatmap.ControlPointInfo.TimingPoints.Add(newPoint);
+ pendingControlPoints.Add(point);
+ pendingControlPointsTime = time;
}
- private void handleDifficultyControlPoint(DifficultyControlPoint newPoint)
+ private void flushPendingPoints()
{
- var existing = beatmap.ControlPointInfo.DifficultyPointAt(newPoint.Time);
+ foreach (var p in pendingControlPoints)
+ beatmap.ControlPointInfo.Add(pendingControlPointsTime, p);
- if (existing.Time == newPoint.Time)
- {
- // autogenerated points should not replace non-autogenerated.
- // this allows for incorrectly ordered timing points to still be correctly handled.
- if (newPoint.AutoGenerated && !existing.AutoGenerated)
- return;
-
- beatmap.ControlPointInfo.DifficultyPoints.Remove(existing);
- }
-
- beatmap.ControlPointInfo.DifficultyPoints.Add(newPoint);
- }
-
- private void handleEffectControlPoint(EffectControlPoint newPoint)
- {
- var existing = beatmap.ControlPointInfo.EffectPointAt(newPoint.Time);
-
- if (existing.Time == newPoint.Time)
- {
- // autogenerated points should not replace non-autogenerated.
- // this allows for incorrectly ordered timing points to still be correctly handled.
- if (newPoint.AutoGenerated && !existing.AutoGenerated)
- return;
-
- beatmap.ControlPointInfo.EffectPoints.Remove(existing);
- }
-
- beatmap.ControlPointInfo.EffectPoints.Add(newPoint);
- }
-
- private void handleSampleControlPoint(SampleControlPoint newPoint)
- {
- var existing = beatmap.ControlPointInfo.SamplePointAt(newPoint.Time);
-
- if (existing.Time == newPoint.Time)
- {
- // autogenerated points should not replace non-autogenerated.
- // this allows for incorrectly ordered timing points to still be correctly handled.
- if (newPoint.AutoGenerated && !existing.AutoGenerated)
- return;
-
- beatmap.ControlPointInfo.SamplePoints.Remove(existing);
- }
-
- beatmap.ControlPointInfo.SamplePoints.Add(newPoint);
+ pendingControlPoints.Clear();
}
private void handleHitObject(string line)
diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
index 83d20da458..2b914669cb 100644
--- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
@@ -189,7 +189,15 @@ namespace osu.Game.Beatmaps.Formats
Foreground = 3
}
- internal class LegacySampleControlPoint : SampleControlPoint, IEquatable
+ internal class LegacyDifficultyControlPoint : DifficultyControlPoint
+ {
+ public LegacyDifficultyControlPoint()
+ {
+ SpeedMultiplierBindable.Precision = double.Epsilon;
+ }
+ }
+
+ internal class LegacySampleControlPoint : SampleControlPoint
{
public int CustomSampleBank;
@@ -203,9 +211,9 @@ namespace osu.Game.Beatmaps.Formats
return baseInfo;
}
- public bool Equals(LegacySampleControlPoint other)
- => base.Equals(other)
- && CustomSampleBank == other?.CustomSampleBank;
+ public override bool EquivalentTo(ControlPoint other) =>
+ base.EquivalentTo(other) && other is LegacySampleControlPoint otherTyped &&
+ CustomSampleBank == otherTyped.CustomSampleBank;
}
}
}
diff --git a/osu.Game/Beatmaps/Formats/LegacyDifficultyCalculatorBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDifficultyCalculatorBeatmapDecoder.cs
index 238187bf8f..527f520172 100644
--- a/osu.Game/Beatmaps/Formats/LegacyDifficultyCalculatorBeatmapDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyDifficultyCalculatorBeatmapDecoder.cs
@@ -28,11 +28,15 @@ namespace osu.Game.Beatmaps.Formats
}
protected override TimingControlPoint CreateTimingControlPoint()
- => new LegacyDifficultyCalculatorControlPoint();
+ => new LegacyDifficultyCalculatorTimingControlPoint();
- private class LegacyDifficultyCalculatorControlPoint : TimingControlPoint
+ private class LegacyDifficultyCalculatorTimingControlPoint : TimingControlPoint
{
- public override double BeatLength { get; set; } = DEFAULT_BEAT_LENGTH;
+ public LegacyDifficultyCalculatorTimingControlPoint()
+ {
+ BeatLengthBindable.MinValue = double.MinValue;
+ BeatLengthBindable.MaxValue = double.MaxValue;
+ }
}
}
}
diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
index 5dbd67d304..f94ab3f27b 100644
--- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
@@ -83,9 +83,7 @@ namespace osu.Game.Beatmaps.Formats
{
storyboardSprite = null;
- EventType type;
-
- if (!Enum.TryParse(split[0], out type))
+ if (!Enum.TryParse(split[0], out EventType type))
throw new InvalidDataException($@"Unknown event type: {split[0]}");
switch (type)
@@ -144,16 +142,16 @@ namespace osu.Game.Beatmaps.Formats
var endTime = split.Length > 3 ? double.Parse(split[3], CultureInfo.InvariantCulture) : double.MaxValue;
var groupNumber = split.Length > 4 ? int.Parse(split[4]) : 0;
timelineGroup = storyboardSprite?.AddTrigger(triggerName, startTime, endTime, groupNumber);
- }
break;
+ }
case "L":
{
var startTime = double.Parse(split[1], CultureInfo.InvariantCulture);
var loopCount = int.Parse(split[2]);
timelineGroup = storyboardSprite?.AddLoop(startTime, loopCount);
- }
break;
+ }
default:
{
@@ -171,16 +169,16 @@ namespace osu.Game.Beatmaps.Formats
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.Alpha.Add(easing, startTime, endTime, startValue, endValue);
- }
break;
+ }
case "S":
{
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startValue), new Vector2(endValue));
- }
break;
+ }
case "V":
{
@@ -189,16 +187,16 @@ namespace osu.Game.Beatmaps.Formats
var endX = split.Length > 6 ? float.Parse(split[6], CultureInfo.InvariantCulture) : startX;
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startX, startY), new Vector2(endX, endY));
- }
break;
+ }
case "R":
{
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathHelper.RadiansToDegrees(startValue), MathHelper.RadiansToDegrees(endValue));
- }
break;
+ }
case "M":
{
@@ -208,24 +206,24 @@ namespace osu.Game.Beatmaps.Formats
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
timelineGroup?.X.Add(easing, startTime, endTime, startX, endX);
timelineGroup?.Y.Add(easing, startTime, endTime, startY, endY);
- }
break;
+ }
case "MX":
{
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.X.Add(easing, startTime, endTime, startValue, endValue);
- }
break;
+ }
case "MY":
{
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.Y.Add(easing, startTime, endTime, startValue, endValue);
- }
break;
+ }
case "C":
{
@@ -238,8 +236,8 @@ namespace osu.Game.Beatmaps.Formats
timelineGroup?.Colour.Add(easing, startTime, endTime,
new Color4(startRed / 255f, startGreen / 255f, startBlue / 255f, 1),
new Color4(endRed / 255f, endGreen / 255f, endBlue / 255f, 1));
- }
break;
+ }
case "P":
{
@@ -259,14 +257,16 @@ namespace osu.Game.Beatmaps.Formats
timelineGroup?.FlipV.Add(easing, startTime, endTime, true, startTime == endTime);
break;
}
- }
+
break;
+ }
default:
throw new InvalidDataException($@"Unknown command type: {commandType}");
}
- }
+
break;
+ }
}
}
}
diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs
index 3fc33e9f52..44d6d33cef 100644
--- a/osu.Game/Beatmaps/WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/WorkingBeatmap.cs
@@ -133,8 +133,10 @@ namespace osu.Game.Beatmaps
obj.ApplyDefaults(converted.ControlPointInfo, converted.BeatmapInfo.BaseDifficulty);
foreach (var mod in mods.OfType())
- foreach (var obj in converted.HitObjects)
- mod.ApplyToHitObject(obj);
+ {
+ foreach (var obj in converted.HitObjects)
+ mod.ApplyToHitObject(obj);
+ }
processor?.PostProcess();
@@ -148,7 +150,7 @@ namespace osu.Game.Beatmaps
public bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false;
- public Task LoadBeatmapAsync() => (beatmapLoadTask ?? (beatmapLoadTask = Task.Factory.StartNew(() =>
+ public Task LoadBeatmapAsync() => beatmapLoadTask ??= Task.Factory.StartNew(() =>
{
// Todo: Handle cancellation during beatmap parsing
var b = GetBeatmap() ?? new Beatmap();
@@ -160,7 +162,7 @@ namespace osu.Game.Beatmaps
b.BeatmapInfo = BeatmapInfo;
return b;
- }, beatmapCancellation.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default)));
+ }, beatmapCancellation.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
public IBeatmap Beatmap
{
diff --git a/osu.Game/Configuration/BackgroundSource.cs b/osu.Game/Configuration/BackgroundSource.cs
new file mode 100644
index 0000000000..5726e96eb1
--- /dev/null
+++ b/osu.Game/Configuration/BackgroundSource.cs
@@ -0,0 +1,11 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Configuration
+{
+ public enum BackgroundSource
+ {
+ Skin,
+ Beatmap
+ }
+}
diff --git a/osu.Game/Configuration/DatabasedConfigManager.cs b/osu.Game/Configuration/DatabasedConfigManager.cs
index 02382cfd2b..b3783b45a8 100644
--- a/osu.Game/Configuration/DatabasedConfigManager.cs
+++ b/osu.Game/Configuration/DatabasedConfigManager.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
@@ -9,8 +10,8 @@ using osu.Game.Rulesets;
namespace osu.Game.Configuration
{
- public abstract class DatabasedConfigManager : ConfigManager
- where T : struct
+ public abstract class DatabasedConfigManager : ConfigManager
+ where TLookup : struct, Enum
{
private readonly SettingsStore settings;
@@ -36,7 +37,7 @@ namespace osu.Game.Configuration
protected override void PerformLoad()
{
databasedSettings = settings.Query(ruleset?.ID, variant);
- legacySettingsExist = databasedSettings.Any(s => int.TryParse(s.Key, out var _));
+ legacySettingsExist = databasedSettings.Any(s => int.TryParse(s.Key, out _));
}
protected override bool PerformSave()
@@ -53,7 +54,7 @@ namespace osu.Game.Configuration
private readonly List dirtySettings = new List();
- protected override void AddBindable(T lookup, Bindable bindable)
+ protected override void AddBindable(TLookup lookup, Bindable bindable)
{
base.AddBindable(lookup, bindable);
diff --git a/osu.Game/Configuration/InMemoryConfigManager.cs b/osu.Game/Configuration/InMemoryConfigManager.cs
index b0dc6b0e9c..ccf697f680 100644
--- a/osu.Game/Configuration/InMemoryConfigManager.cs
+++ b/osu.Game/Configuration/InMemoryConfigManager.cs
@@ -1,12 +1,13 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Configuration;
namespace osu.Game.Configuration
{
- public class InMemoryConfigManager : ConfigManager
- where T : struct
+ public class InMemoryConfigManager : ConfigManager
+ where TLookup : struct, Enum
{
public InMemoryConfigManager()
{
diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs
index c0ce08ba08..b71463841a 100644
--- a/osu.Game/Configuration/OsuConfigManager.cs
+++ b/osu.Game/Configuration/OsuConfigManager.cs
@@ -117,6 +117,8 @@ namespace osu.Game.Configuration
Set(OsuSetting.UIHoldActivationDelay, 200f, 0f, 500f, 50f);
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
+
+ Set(OsuSetting.MenuBackgroundSource, BackgroundSource.Skin);
}
public OsuConfigManager(Storage storage)
@@ -186,6 +188,7 @@ namespace osu.Game.Configuration
UIScale,
IntroSequence,
UIHoldActivationDelay,
- HitLighting
+ HitLighting,
+ MenuBackgroundSource
}
}
diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs
new file mode 100644
index 0000000000..056fa8bcc0
--- /dev/null
+++ b/osu.Game/Configuration/SettingSourceAttribute.cs
@@ -0,0 +1,110 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using JetBrains.Annotations;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.UserInterface;
+using osu.Game.Overlays.Settings;
+
+namespace osu.Game.Configuration
+{
+ ///
+ /// An attribute to mark a bindable as being exposed to the user via settings controls.
+ /// Can be used in conjunction with to automatically create UI controls.
+ ///
+ [MeansImplicitUse]
+ [AttributeUsage(AttributeTargets.Property)]
+ public class SettingSourceAttribute : Attribute
+ {
+ public string Label { get; }
+
+ public string Description { get; }
+
+ public SettingSourceAttribute(string label, string description = null)
+ {
+ Label = label ?? string.Empty;
+ Description = description ?? string.Empty;
+ }
+ }
+
+ public static class SettingSourceExtensions
+ {
+ public static IEnumerable CreateSettingsControls(this object obj)
+ {
+ foreach (var property in obj.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance))
+ {
+ var attr = property.GetCustomAttribute(true);
+
+ if (attr == null)
+ continue;
+
+ var prop = property.GetValue(obj);
+
+ switch (prop)
+ {
+ case BindableNumber bNumber:
+ yield return new SettingsSlider
+ {
+ LabelText = attr.Label,
+ Bindable = bNumber
+ };
+
+ break;
+
+ case BindableNumber bNumber:
+ yield return new SettingsSlider
+ {
+ LabelText = attr.Label,
+ Bindable = bNumber
+ };
+
+ break;
+
+ case BindableNumber bNumber:
+ yield return new SettingsSlider
+ {
+ LabelText = attr.Label,
+ Bindable = bNumber
+ };
+
+ break;
+
+ case Bindable bBool:
+ yield return new SettingsCheckbox
+ {
+ LabelText = attr.Label,
+ Bindable = bBool
+ };
+
+ break;
+
+ case Bindable bString:
+ yield return new SettingsTextBox
+ {
+ LabelText = attr.Label,
+ Bindable = bString
+ };
+
+ break;
+
+ case IBindable bindable:
+ var dropdownType = typeof(SettingsEnumDropdown<>).MakeGenericType(bindable.GetType().GetGenericArguments()[0]);
+ var dropdown = (Drawable)Activator.CreateInstance(dropdownType);
+
+ dropdown.GetType().GetProperty(nameof(IHasCurrentValue
public class Background : CompositeDrawable
{
+ private const float blur_scale = 0.5f;
+
public readonly Sprite Sprite;
private readonly string textureName;
@@ -43,7 +45,7 @@ namespace osu.Game.Graphics.Backgrounds
Sprite.Texture = textures.Get(textureName);
}
- public Vector2 BlurSigma => bufferedContainer?.BlurSigma ?? Vector2.Zero;
+ public Vector2 BlurSigma => bufferedContainer?.BlurSigma / blur_scale ?? Vector2.Zero;
///
/// Smoothly adjusts over time.
@@ -64,7 +66,10 @@ namespace osu.Game.Graphics.Backgrounds
});
}
- bufferedContainer?.BlurTo(newBlurSigma, duration, easing);
+ if (bufferedContainer != null)
+ bufferedContainer.FrameBufferScale = newBlurSigma == Vector2.Zero ? Vector2.One : new Vector2(blur_scale);
+
+ bufferedContainer?.BlurTo(newBlurSigma * blur_scale, duration, easing);
}
}
}
diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
new file mode 100644
index 0000000000..387e189dc4
--- /dev/null
+++ b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
@@ -0,0 +1,28 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Textures;
+using osu.Game.Beatmaps;
+
+namespace osu.Game.Graphics.Backgrounds
+{
+ public class BeatmapBackground : Background
+ {
+ public readonly WorkingBeatmap Beatmap;
+
+ private readonly string fallbackTextureName;
+
+ public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1")
+ {
+ Beatmap = beatmap;
+ this.fallbackTextureName = fallbackTextureName;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(TextureStore textures)
+ {
+ Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
+ }
+ }
+}
diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs
index dffa0c4fd5..6d88808150 100644
--- a/osu.Game/Graphics/Backgrounds/Triangles.cs
+++ b/osu.Game/Graphics/Backgrounds/Triangles.cs
@@ -111,7 +111,7 @@ namespace osu.Game.Graphics.Backgrounds
float adjustedAlpha = HideAlphaDiscrepancies
// Cubically scale alpha to make it drop off more sharply.
- ? (float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3)
+ ? MathF.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3)
: 1;
float elapsedSeconds = (float)Time.Elapsed / 1000;
diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
index 370d044ba4..2e76ab964f 100644
--- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
+++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
@@ -104,14 +104,10 @@ namespace osu.Game.Graphics.Containers
defaultTiming = new TimingControlPoint
{
BeatLength = default_beat_length,
- AutoGenerated = true,
- Time = 0
};
defaultEffect = new EffectControlPoint
{
- Time = 0,
- AutoGenerated = true,
KiaiMode = false,
OmitFirstBarLine = false
};
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index 15068d81c0..2bbac92f7f 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -8,9 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
using osu.Framework.Graphics;
-using osu.Framework.Logging;
-using osu.Game.Overlays;
-using osu.Game.Overlays.Notifications;
using osu.Game.Users;
namespace osu.Game.Graphics.Containers
@@ -22,23 +19,8 @@ namespace osu.Game.Graphics.Containers
{
}
- private OsuGame game;
- private ChannelManager channelManager;
- private Action showNotImplementedError;
-
- [BackgroundDependencyLoader(true)]
- private void load(OsuGame game, NotificationOverlay notifications, ChannelManager channelManager)
- {
- // will be null in tests
- this.game = game;
- this.channelManager = channelManager;
-
- showNotImplementedError = () => notifications?.Post(new SimpleNotification
- {
- Text = @"This link type is not yet supported!",
- Icon = FontAwesome.Solid.LifeRing,
- });
- }
+ [Resolved(CanBeNull = true)]
+ private OsuGame game { get; set; }
public void AddLinks(string text, List links)
{
@@ -56,85 +38,47 @@ namespace osu.Game.Graphics.Containers
foreach (var link in links)
{
AddText(text.Substring(previousLinkEnd, link.Index - previousLinkEnd));
- AddLink(text.Substring(link.Index, link.Length), link.Url, link.Action, link.Argument);
+ AddLink(text.Substring(link.Index, link.Length), link.Action, link.Argument ?? link.Url);
previousLinkEnd = link.Index + link.Length;
}
AddText(text.Substring(previousLinkEnd));
}
- public IEnumerable AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action creationParameters = null)
- => createLink(AddText(text, creationParameters), text, url, linkType, linkArgument, tooltipText);
+ public void AddLink(string text, string url, Action creationParameters = null) =>
+ createLink(AddText(text, creationParameters), new LinkDetails(LinkAction.External, url), url);
- public IEnumerable AddLink(string text, Action action, string tooltipText = null, Action creationParameters = null)
- => createLink(AddText(text, creationParameters), text, tooltipText: tooltipText, action: action);
+ public void AddLink(string text, Action action, string tooltipText = null, Action creationParameters = null)
+ => createLink(AddText(text, creationParameters), new LinkDetails(LinkAction.Custom, null), tooltipText, action);
- public IEnumerable AddLink(IEnumerable text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
+ public void AddLink(string text, LinkAction action, string argument, string tooltipText = null, Action creationParameters = null)
+ => createLink(AddText(text, creationParameters), new LinkDetails(action, argument), null);
+
+ public void AddLink(IEnumerable text, LinkAction action = LinkAction.External, string linkArgument = null, string tooltipText = null)
{
foreach (var t in text)
AddArbitraryDrawable(t);
- return createLink(text, null, url, linkType, linkArgument, tooltipText);
+ createLink(text, new LinkDetails(action, linkArgument), tooltipText);
}
- public IEnumerable AddUserLink(User user, Action creationParameters = null)
- => createLink(AddText(user.Username, creationParameters), user.Username, null, LinkAction.OpenUserProfile, user.Id.ToString(), "View profile");
+ public void AddUserLink(User user, Action creationParameters = null)
+ => createLink(AddText(user.Username, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user.Id.ToString()), "View Profile");
- private IEnumerable createLink(IEnumerable drawables, string text, string url = null, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action action = null)
+ private void createLink(IEnumerable drawables, LinkDetails link, string tooltipText, Action action = null)
{
AddInternal(new DrawableLinkCompiler(drawables.OfType().ToList())
{
RelativeSizeAxes = Axes.Both,
- TooltipText = tooltipText ?? (url != text ? url : string.Empty),
- Action = action ?? (() =>
+ TooltipText = tooltipText,
+ Action = () =>
{
- switch (linkType)
- {
- case LinkAction.OpenBeatmap:
- // TODO: proper query params handling
- if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
- game?.ShowBeatmap(beatmapId);
- break;
-
- case LinkAction.OpenBeatmapSet:
- if (int.TryParse(linkArgument, out int setId))
- game?.ShowBeatmapSet(setId);
- break;
-
- case LinkAction.OpenChannel:
- try
- {
- channelManager?.OpenChannel(linkArgument);
- }
- catch (ChannelNotFoundException)
- {
- Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
- }
-
- break;
-
- case LinkAction.OpenEditorTimestamp:
- case LinkAction.JoinMultiplayerMatch:
- case LinkAction.Spectate:
- showNotImplementedError?.Invoke();
- break;
-
- case LinkAction.External:
- game?.OpenUrlExternally(url);
- break;
-
- case LinkAction.OpenUserProfile:
- if (long.TryParse(linkArgument, out long userId))
- game?.ShowUser(userId);
- break;
-
- default:
- throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
- }
- }),
+ if (action != null)
+ action();
+ else
+ game?.HandleLink(link);
+ },
});
-
- return drawables;
}
// We want the compilers to always be visible no matter where they are, so RelativeSizeAxes is used.
diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs
index b117d71006..facf70b47a 100644
--- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs
+++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs
@@ -67,33 +67,21 @@ namespace osu.Game.Graphics.Containers
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => BlockScreenWideMouse || base.ReceivePositionalInputAt(screenSpacePos);
- protected override bool OnClick(ClickEvent e)
- {
- if (!base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
- Hide();
+ private bool closeOnMouseUp;
- return base.OnClick(e);
+ protected override bool OnMouseDown(MouseDownEvent e)
+ {
+ closeOnMouseUp = !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition);
+
+ return base.OnMouseDown(e);
}
- private bool closeOnDragEnd;
-
- protected override bool OnDragStart(DragStartEvent e)
+ protected override bool OnMouseUp(MouseUpEvent e)
{
- if (!base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
- closeOnDragEnd = true;
-
- return base.OnDragStart(e);
- }
-
- protected override bool OnDragEnd(DragEndEvent e)
- {
- if (closeOnDragEnd)
- {
+ if (closeOnMouseUp && !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
Hide();
- closeOnDragEnd = false;
- }
- return base.OnDragEnd(e);
+ return base.OnMouseUp(e);
}
public virtual bool OnPressed(GlobalAction action)
diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs
index f65a0a469a..bf743b90ed 100644
--- a/osu.Game/Graphics/Containers/ParallaxContainer.cs
+++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Input;
@@ -48,7 +49,7 @@ namespace osu.Game.Graphics.Containers
if (!parallaxEnabled.Value)
{
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint);
- content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount));
+ content.Scale = new Vector2(1 + Math.Abs(ParallaxAmount));
}
};
}
@@ -69,10 +70,12 @@ namespace osu.Game.Graphics.Containers
{
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
- double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000);
+ const float parallax_duration = 100;
- content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint);
- content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint);
+ double elapsed = Math.Clamp(Clock.ElapsedFrameTime, 0, parallax_duration);
+
+ content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, parallax_duration, Easing.OutQuint);
+ content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint);
}
firstUpdate = false;
diff --git a/osu.Game/Graphics/Containers/ShakeContainer.cs b/osu.Game/Graphics/Containers/ShakeContainer.cs
index e5a6bcc28e..dca9df1e98 100644
--- a/osu.Game/Graphics/Containers/ShakeContainer.cs
+++ b/osu.Game/Graphics/Containers/ShakeContainer.cs
@@ -43,9 +43,11 @@ namespace osu.Game.Graphics.Containers
// if we don't have enough time for the second shake, skip it.
if (!maximumLength.HasValue || maximumLength >= ShakeDuration * 4)
+ {
sequence = sequence
.MoveToX(shake_amount, ShakeDuration, Easing.InOutSine).Then()
.MoveToX(-shake_amount, ShakeDuration, Easing.InOutSine).Then();
+ }
sequence.MoveToX(0, ShakeDuration / 2, Easing.InSine);
}
diff --git a/osu.Game/Graphics/Containers/WaveContainer.cs b/osu.Game/Graphics/Containers/WaveContainer.cs
index c01674f5b4..8b87ddaa20 100644
--- a/osu.Game/Graphics/Containers/WaveContainer.cs
+++ b/osu.Game/Graphics/Containers/WaveContainer.cs
@@ -159,8 +159,15 @@ namespace osu.Game.Graphics.Containers
Height = Parent.Parent.DrawSize.Y * 1.5f;
}
- protected override void PopIn() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show);
- protected override void PopOut() => this.MoveToY(Parent.Parent.DrawSize.Y, DISAPPEAR_DURATION, easing_hide);
+ protected override void PopIn() => Schedule(() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show));
+
+ protected override void PopOut()
+ {
+ double duration = IsLoaded ? DISAPPEAR_DURATION : 0;
+
+ // scheduling is required as parent may not be present at the time this is called.
+ Schedule(() => this.MoveToY(Parent.Parent.DrawSize.Y, duration, easing_hide));
+ }
}
}
}
diff --git a/osu.Game/Graphics/IHasAccentColour.cs b/osu.Game/Graphics/IHasAccentColour.cs
index 1a66819379..af497da70f 100644
--- a/osu.Game/Graphics/IHasAccentColour.cs
+++ b/osu.Game/Graphics/IHasAccentColour.cs
@@ -24,7 +24,7 @@ namespace osu.Game.Graphics
///
/// A to which further transforms can be added.
public static TransformSequence FadeAccent(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
- where T : IHasAccentColour
+ where T : class, IHasAccentColour
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
///
diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs
index af66f57f14..2dc12b3e67 100644
--- a/osu.Game/Graphics/OsuColour.cs
+++ b/osu.Game/Graphics/OsuColour.cs
@@ -38,7 +38,7 @@ namespace osu.Game.Graphics
}
}
- public Color4 ForDifficultyRating(DifficultyRating difficulty)
+ public Color4 ForDifficultyRating(DifficultyRating difficulty, bool useLighterColour = false)
{
switch (difficulty)
{
@@ -56,10 +56,10 @@ namespace osu.Game.Graphics
return Pink;
case DifficultyRating.Expert:
- return Purple;
+ return useLighterColour ? PurpleLight : Purple;
case DifficultyRating.ExpertPlus:
- return Gray0;
+ return useLighterColour ? Gray9 : Gray0;
}
}
diff --git a/osu.Game/Graphics/Sprites/OsuSpriteText.cs b/osu.Game/Graphics/Sprites/OsuSpriteText.cs
index ed771bb03f..cd988c347b 100644
--- a/osu.Game/Graphics/Sprites/OsuSpriteText.cs
+++ b/osu.Game/Graphics/Sprites/OsuSpriteText.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Graphics.Sprites
public static class OsuSpriteTextTransformExtensions
{
///
- /// Sets to a new value after a duration.
+ /// Sets Text to a new value after a duration.
///
/// A to which further transforms can be added.
public static TransformSequence TransformTextTo(this T spriteText, string newText, double duration = 0, Easing easing = Easing.None)
@@ -27,7 +27,7 @@ namespace osu.Game.Graphics.Sprites
=> spriteText.TransformTo(nameof(OsuSpriteText.Text), newText, duration, easing);
///
- /// Sets to a new value after a duration.
+ /// Sets Text to a new value after a duration.
///
/// A to which further transforms can be added.
public static TransformSequence TransformTextTo(this TransformSequence t, string newText, double duration = 0, Easing easing = Easing.None)
diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs
index f8d5955503..0be928cf83 100644
--- a/osu.Game/Graphics/UserInterface/Bar.cs
+++ b/osu.Game/Graphics/UserInterface/Bar.cs
@@ -1,12 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using System;
namespace osu.Game.Graphics.UserInterface
{
@@ -29,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface
get => length;
set
{
- length = MathHelper.Clamp(value, 0, 1);
+ length = Math.Clamp(value, 0, 1);
updateBarLength();
}
}
diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs
index 927ad13829..aed07e56ee 100644
--- a/osu.Game/Graphics/UserInterface/DialogButton.cs
+++ b/osu.Game/Graphics/UserInterface/DialogButton.cs
@@ -20,9 +20,10 @@ namespace osu.Game.Graphics.UserInterface
{
public class DialogButton : OsuClickableContainer
{
+ private const float idle_width = 0.8f;
private const float hover_width = 0.9f;
+
private const float hover_duration = 500;
- private const float glow_fade_duration = 250;
private const float click_duration = 200;
public readonly BindableBool Selected = new BindableBool();
@@ -99,7 +100,7 @@ namespace osu.Game.Graphics.UserInterface
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
- Width = 0.8f,
+ Width = idle_width,
Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffectParameters
@@ -199,26 +200,50 @@ namespace osu.Game.Graphics.UserInterface
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceivePositionalInputAt(screenSpacePos);
+ private bool clickAnimating;
+
protected override bool OnClick(ClickEvent e)
{
- colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In);
- flash();
-
- this.Delay(click_duration).Schedule(delegate
+ var flash = new Box
{
- colourContainer.ResizeTo(new Vector2(0.8f, 1f));
- spriteText.Spacing = Vector2.Zero;
- glowContainer.FadeOut();
- });
+ RelativeSizeAxes = Axes.Both,
+ Colour = ButtonColour,
+ Blending = BlendingParameters.Additive,
+ Alpha = 0.05f
+ };
+
+ colourContainer.Add(flash);
+ flash.FadeOutFromOne(100).Expire();
+
+ clickAnimating = true;
+ colourContainer.ResizeWidthTo(colourContainer.Width * 1.05f, 100, Easing.OutQuint)
+ .OnComplete(_ =>
+ {
+ clickAnimating = false;
+ Selected.TriggerChange();
+ });
return base.OnClick(e);
}
+ protected override bool OnMouseDown(MouseDownEvent e)
+ {
+ colourContainer.ResizeWidthTo(hover_width * 0.98f, click_duration * 4, Easing.OutQuad);
+ return base.OnMouseDown(e);
+ }
+
+ protected override bool OnMouseUp(MouseUpEvent e)
+ {
+ if (Selected.Value)
+ colourContainer.ResizeWidthTo(hover_width, click_duration, Easing.In);
+ return base.OnMouseUp(e);
+ }
+
protected override bool OnHover(HoverEvent e)
{
base.OnHover(e);
-
Selected.Value = true;
+
return true;
}
@@ -230,36 +255,23 @@ namespace osu.Game.Graphics.UserInterface
private void selectionChanged(ValueChangedEvent args)
{
+ if (clickAnimating)
+ return;
+
if (args.NewValue)
{
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
- colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);
- glowContainer.FadeIn(glow_fade_duration, Easing.Out);
+ colourContainer.ResizeWidthTo(hover_width, hover_duration, Easing.OutElastic);
+ glowContainer.FadeIn(hover_duration, Easing.OutQuint);
}
else
{
- colourContainer.ResizeTo(new Vector2(0.8f, 1f), hover_duration, Easing.OutElastic);
+ colourContainer.ResizeWidthTo(idle_width, hover_duration, Easing.OutElastic);
spriteText.TransformSpacingTo(Vector2.Zero, hover_duration, Easing.OutElastic);
- glowContainer.FadeOut(glow_fade_duration, Easing.Out);
+ glowContainer.FadeOut(hover_duration, Easing.OutQuint);
}
}
- private void flash()
- {
- var flash = new Box
- {
- RelativeSizeAxes = Axes.Both
- };
-
- colourContainer.Add(flash);
-
- flash.Colour = ButtonColour;
- flash.Blending = BlendingParameters.Additive;
- flash.Alpha = 0.3f;
- flash.FadeOutFromOne(click_duration);
- flash.Expire();
- }
-
private void updateGlow()
{
leftGlow.Colour = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
diff --git a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs b/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs
index b7d2222f33..f2f6dd429b 100644
--- a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs
+++ b/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs
@@ -6,16 +6,17 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.Color4Extensions;
+using osuTK;
namespace osu.Game.Graphics.UserInterface
{
- public class DimmedLoadingLayer : VisibilityContainer
+ public class DimmedLoadingLayer : OverlayContainer
{
private const float transition_duration = 250;
private readonly LoadingAnimation loading;
- public DimmedLoadingLayer()
+ public DimmedLoadingLayer(float dimAmount = 0.5f, float iconScale = 1f)
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
@@ -23,9 +24,9 @@ namespace osu.Game.Graphics.UserInterface
new Box
{
RelativeSizeAxes = Axes.Both,
- Colour = Color4.Black.Opacity(0.5f),
+ Colour = Color4.Black.Opacity(dimAmount),
},
- loading = new LoadingAnimation(),
+ loading = new LoadingAnimation { Scale = new Vector2(iconScale) },
};
}
diff --git a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
new file mode 100644
index 0000000000..591ed3df83
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
@@ -0,0 +1,133 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Audio;
+using osu.Framework.Audio.Sample;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics.Sprites;
+using osuTK.Graphics;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ public class DrawableOsuMenuItem : Menu.DrawableMenuItem
+ {
+ public const int MARGIN_HORIZONTAL = 17;
+ public const int MARGIN_VERTICAL = 4;
+ private const int text_size = 17;
+ private const int transition_length = 80;
+
+ private SampleChannel sampleClick;
+ private SampleChannel sampleHover;
+
+ private TextContainer text;
+
+ public DrawableOsuMenuItem(MenuItem item)
+ : base(item)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(AudioManager audio)
+ {
+ sampleHover = audio.Samples.Get(@"UI/generic-hover");
+ sampleClick = audio.Samples.Get(@"UI/generic-select");
+
+ BackgroundColour = Color4.Transparent;
+ BackgroundColourHover = OsuColour.FromHex(@"172023");
+
+ updateTextColour();
+ }
+
+ private void updateTextColour()
+ {
+ switch ((Item as OsuMenuItem)?.Type)
+ {
+ default:
+ case MenuItemType.Standard:
+ text.Colour = Color4.White;
+ break;
+
+ case MenuItemType.Destructive:
+ text.Colour = Color4.Red;
+ break;
+
+ case MenuItemType.Highlighted:
+ text.Colour = OsuColour.FromHex(@"ffcc22");
+ break;
+ }
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ sampleHover.Play();
+ text.BoldText.FadeIn(transition_length, Easing.OutQuint);
+ text.NormalText.FadeOut(transition_length, Easing.OutQuint);
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ text.BoldText.FadeOut(transition_length, Easing.OutQuint);
+ text.NormalText.FadeIn(transition_length, Easing.OutQuint);
+ base.OnHoverLost(e);
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ sampleClick.Play();
+ return base.OnClick(e);
+ }
+
+ protected sealed override Drawable CreateContent() => text = CreateTextContainer();
+ protected virtual TextContainer CreateTextContainer() => new TextContainer();
+
+ protected class TextContainer : Container, IHasText
+ {
+ public string Text
+ {
+ get => NormalText.Text;
+ set
+ {
+ NormalText.Text = value;
+ BoldText.Text = value;
+ }
+ }
+
+ public readonly SpriteText NormalText;
+ public readonly SpriteText BoldText;
+
+ public TextContainer()
+ {
+ Anchor = Anchor.CentreLeft;
+ Origin = Anchor.CentreLeft;
+
+ AutoSizeAxes = Axes.Both;
+
+ Children = new Drawable[]
+ {
+ NormalText = new OsuSpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: text_size),
+ Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL, Vertical = MARGIN_VERTICAL },
+ },
+ BoldText = new OsuSpriteText
+ {
+ AlwaysPresent = true,
+ Alpha = 0,
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
+ Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL, Vertical = MARGIN_VERTICAL },
+ }
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs
new file mode 100644
index 0000000000..3dc99f2dbe
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs
@@ -0,0 +1,72 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osuTK;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ public class DrawableStatefulMenuItem : DrawableOsuMenuItem
+ {
+ protected new StatefulMenuItem Item => (StatefulMenuItem)base.Item;
+
+ public DrawableStatefulMenuItem(StatefulMenuItem item)
+ : base(item)
+ {
+ }
+
+ protected override TextContainer CreateTextContainer() => new ToggleTextContainer(Item);
+
+ private class ToggleTextContainer : TextContainer
+ {
+ private readonly StatefulMenuItem menuItem;
+ private readonly Bindable
public class OsuButton : Button
{
- private Box hover;
+ public string Text
+ {
+ get => SpriteText?.Text;
+ set
+ {
+ if (SpriteText != null)
+ SpriteText.Text = value;
+ }
+ }
- public OsuButton()
+ private Color4? backgroundColour;
+
+ public Color4 BackgroundColour
+ {
+ set
+ {
+ backgroundColour = value;
+ Background.FadeColour(value);
+ }
+ }
+
+ protected override Container Content { get; }
+
+ protected Box Hover;
+ protected Box Background;
+ protected SpriteText SpriteText;
+
+ public OsuButton(HoverSampleSet? hoverSounds = HoverSampleSet.Loud)
{
Height = 40;
- Content.Masking = true;
- Content.CornerRadius = 5;
+ AddInternal(Content = new Container
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Masking = true,
+ CornerRadius = 5,
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ Background = new Box
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ },
+ Hover = new Box
+ {
+ Alpha = 0,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.White.Opacity(.1f),
+ Blending = BlendingParameters.Additive,
+ Depth = float.MinValue
+ },
+ SpriteText = CreateText(),
+ }
+ });
+
+ if (hoverSounds.HasValue)
+ AddInternal(new HoverClickSounds(hoverSounds.Value));
+
+ Enabled.BindValueChanged(enabledChanged, true);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
- BackgroundColour = colours.BlueDark;
-
- AddRange(new Drawable[]
- {
- hover = new Box
- {
- RelativeSizeAxes = Axes.Both,
- Blending = BlendingParameters.Additive,
- Colour = Color4.White.Opacity(0.1f),
- Alpha = 0,
- Depth = -1
- },
- new HoverClickSounds(HoverSampleSet.Loud),
- });
+ if (backgroundColour == null)
+ BackgroundColour = colours.BlueDark;
Enabled.ValueChanged += enabledChanged;
Enabled.TriggerChange();
}
- private void enabledChanged(ValueChangedEvent e)
+ protected override bool OnClick(ClickEvent e)
{
- this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
+ if (Enabled.Value)
+ {
+ Debug.Assert(backgroundColour != null);
+ Background.FlashColour(backgroundColour.Value, 200);
+ }
+
+ return base.OnClick(e);
}
protected override bool OnHover(HoverEvent e)
{
- hover.FadeIn(200);
+ if (Enabled.Value)
+ Hover.FadeIn(200, Easing.OutQuint);
+
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
- hover.FadeOut(200);
base.OnHoverLost(e);
+
+ Hover.FadeOut(300);
}
protected override bool OnMouseDown(MouseDownEvent e)
@@ -80,12 +135,17 @@ namespace osu.Game.Graphics.UserInterface
return base.OnMouseUp(e);
}
- protected override SpriteText CreateText() => new OsuSpriteText
+ protected virtual SpriteText CreateText() => new OsuSpriteText
{
Depth = -1,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Font = OsuFont.GetFont(weight: FontWeight.Bold)
};
+
+ private void enabledChanged(ValueChangedEvent e)
+ {
+ this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
+ }
}
}
diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs
index cea8427296..4b629080e1 100644
--- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs
+++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs
@@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects;
+using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
@@ -35,5 +36,7 @@ namespace osu.Game.Graphics.UserInterface
protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint);
protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint);
+
+ protected override Menu CreateSubMenu() => new OsuContextMenu();
}
}
diff --git a/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs
index e132027787..528d7d60f8 100644
--- a/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs
+++ b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs
@@ -6,12 +6,10 @@ using System;
namespace osu.Game.Graphics.UserInterface
{
public class OsuEnumDropdown : OsuDropdown
+ where T : struct, Enum
{
public OsuEnumDropdown()
{
- if (!typeof(T).IsEnum)
- throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument");
-
Items = (T[])Enum.GetValues(typeof(T));
}
}
diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs
index c4c6950eb1..e7bf4f66ee 100644
--- a/osu.Game/Graphics/UserInterface/OsuMenu.cs
+++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs
@@ -1,18 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Allocation;
-using osu.Framework.Audio;
-using osu.Framework.Audio.Sample;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
-using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
-using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Graphics.UserInterface
@@ -45,7 +39,16 @@ namespace osu.Game.Graphics.UserInterface
}
}
- protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuMenuItem(item);
+ protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item)
+ {
+ switch (item)
+ {
+ case StatefulMenuItem stateful:
+ return new DrawableStatefulMenuItem(stateful);
+ }
+
+ return new DrawableOsuMenuItem(item);
+ }
protected override ScrollContainer CreateScrollContainer(Direction direction) => new OsuScrollContainer(direction);
@@ -53,122 +56,5 @@ namespace osu.Game.Graphics.UserInterface
{
Anchor = Direction == Direction.Horizontal ? Anchor.BottomLeft : Anchor.TopRight
};
-
- protected class DrawableOsuMenuItem : DrawableMenuItem
- {
- private const int margin_horizontal = 17;
- private const int text_size = 17;
- private const int transition_length = 80;
- public const int MARGIN_VERTICAL = 4;
-
- private SampleChannel sampleClick;
- private SampleChannel sampleHover;
-
- private TextContainer text;
-
- public DrawableOsuMenuItem(MenuItem item)
- : base(item)
- {
- }
-
- [BackgroundDependencyLoader]
- private void load(AudioManager audio)
- {
- sampleHover = audio.Samples.Get(@"UI/generic-hover");
- sampleClick = audio.Samples.Get(@"UI/generic-select");
-
- BackgroundColour = Color4.Transparent;
- BackgroundColourHover = OsuColour.FromHex(@"172023");
-
- updateTextColour();
- }
-
- private void updateTextColour()
- {
- switch ((Item as OsuMenuItem)?.Type)
- {
- default:
- case MenuItemType.Standard:
- text.Colour = Color4.White;
- break;
-
- case MenuItemType.Destructive:
- text.Colour = Color4.Red;
- break;
-
- case MenuItemType.Highlighted:
- text.Colour = OsuColour.FromHex(@"ffcc22");
- break;
- }
- }
-
- protected override bool OnHover(HoverEvent e)
- {
- sampleHover.Play();
- text.BoldText.FadeIn(transition_length, Easing.OutQuint);
- text.NormalText.FadeOut(transition_length, Easing.OutQuint);
- return base.OnHover(e);
- }
-
- protected override void OnHoverLost(HoverLostEvent e)
- {
- text.BoldText.FadeOut(transition_length, Easing.OutQuint);
- text.NormalText.FadeIn(transition_length, Easing.OutQuint);
- base.OnHoverLost(e);
- }
-
- protected override bool OnClick(ClickEvent e)
- {
- sampleClick.Play();
- return base.OnClick(e);
- }
-
- protected sealed override Drawable CreateContent() => text = CreateTextContainer();
- protected virtual TextContainer CreateTextContainer() => new TextContainer();
-
- protected class TextContainer : Container, IHasText
- {
- public string Text
- {
- get => NormalText.Text;
- set
- {
- NormalText.Text = value;
- BoldText.Text = value;
- }
- }
-
- public readonly SpriteText NormalText;
- public readonly SpriteText BoldText;
-
- public TextContainer()
- {
- Anchor = Anchor.CentreLeft;
- Origin = Anchor.CentreLeft;
-
- AutoSizeAxes = Axes.Both;
-
- Children = new Drawable[]
- {
- NormalText = new OsuSpriteText
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: text_size),
- Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
- },
- BoldText = new OsuSpriteText
- {
- AlwaysPresent = true,
- Alpha = 0,
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
- Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
- }
- };
- }
- }
- }
}
}
diff --git a/osu.Game/Graphics/UserInterface/OsuMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuMenuItem.cs
index b7aa666302..0fe41937ce 100644
--- a/osu.Game/Graphics/UserInterface/OsuMenuItem.cs
+++ b/osu.Game/Graphics/UserInterface/OsuMenuItem.cs
@@ -11,9 +11,8 @@ namespace osu.Game.Graphics.UserInterface
public readonly MenuItemType Type;
public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard)
- : base(text)
+ : this(text, type, null)
{
- Type = type;
}
public OsuMenuItem(string text, MenuItemType type, Action action)
diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
index 5c706781e6..563dc2dad9 100644
--- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
+++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
@@ -17,7 +17,7 @@ using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface
{
public class OsuSliderBar : SliderBar, IHasTooltip, IHasAccentColour
- where T : struct, IEquatable, IComparable, IConvertible
+ where T : struct, IEquatable, IComparable, IConvertible
{
///
/// Maximum number of decimal digits to be displayed in the tooltip.
@@ -151,18 +151,18 @@ namespace osu.Game.Graphics.UserInterface
private void updateTooltipText(T value)
{
if (CurrentNumber.IsInteger)
- TooltipText = ((int)Convert.ChangeType(value, typeof(int))).ToString("N0");
+ TooltipText = value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0");
else
{
- double floatValue = (double)Convert.ChangeType(value, typeof(double));
- double floatMinValue = (double)Convert.ChangeType(CurrentNumber.MinValue, typeof(double));
- double floatMaxValue = (double)Convert.ChangeType(CurrentNumber.MaxValue, typeof(double));
+ double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
+ double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
+ double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
if (floatMaxValue == 1 && floatMinValue >= -1)
TooltipText = floatValue.ToString("P0");
else
{
- var decimalPrecision = normalise((decimal)Convert.ChangeType(CurrentNumber.Precision, typeof(decimal)), max_decimal_digits);
+ var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
// Find the number of significant digits (we could have less than 5 after normalize())
var significantDigits = findPrecision(decimalPrecision);
@@ -175,9 +175,9 @@ namespace osu.Game.Graphics.UserInterface
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
- leftBox.Scale = new Vector2(MathHelper.Clamp(
+ leftBox.Scale = new Vector2(Math.Clamp(
Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
- rightBox.Scale = new Vector2(MathHelper.Clamp(
+ rightBox.Scale = new Vector2(Math.Clamp(
DrawWidth - Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
}
diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs
index c55d14456b..064cba6adf 100644
--- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs
+++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs
@@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface
protected virtual float StripHeight() => 1;
///
- /// Whether entries should be automatically populated if is an type.
+ /// Whether entries should be automatically populated if is an type.
///
protected virtual bool AddEnumEntriesAutomatically => true;
@@ -51,8 +51,10 @@ namespace osu.Game.Graphics.UserInterface
});
if (isEnumType && AddEnumEntriesAutomatically)
+ {
foreach (var val in (T[])Enum.GetValues(typeof(T)))
AddItem(val);
+ }
}
[BackgroundDependencyLoader]
@@ -97,7 +99,7 @@ namespace osu.Game.Graphics.UserInterface
// dont bother calculating if the strip is invisible
if (strip.Colour.MaxAlpha > 0)
- strip.Width = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000), strip.Width, StripWidth(), 0, 500, Easing.OutQuint);
+ strip.Width = Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, 1000), strip.Width, StripWidth(), 0, 500, Easing.OutQuint);
}
public class OsuTabItem : TabItem, IHasAccentColour
diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs
index 8254bdda7c..064c663d59 100644
--- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs
+++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs
@@ -41,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Increment(double amount)
{
- Current.Value = Current.Value + amount;
+ Current.Value += amount;
}
}
}
diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs
index 63062cdc9d..24d8009f40 100644
--- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs
+++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs
@@ -43,16 +43,19 @@ namespace osu.Game.Graphics.UserInterface
protected override string FormatCount(double count)
{
string format = new string('0', (int)LeadingZeroes);
+
if (UseCommaSeparator)
+ {
for (int i = format.Length - 3; i > 0; i -= 3)
format = format.Insert(i, @",");
+ }
return ((long)count).ToString(format);
}
public override void Increment(double amount)
{
- Current.Value = Current.Value + amount;
+ Current.Value += amount;
}
}
}
diff --git a/osu.Game/Graphics/UserInterface/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs
index c3efe2ed45..ff3618b263 100644
--- a/osu.Game/Graphics/UserInterface/SearchTextBox.cs
+++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs
@@ -14,8 +14,6 @@ namespace osu.Game.Graphics.UserInterface
{
protected virtual bool AllowCommit => false;
- public override bool HandleLeftRightArrows => false;
-
public SearchTextBox()
{
Height = 35;
@@ -37,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
public override bool OnPressed(PlatformAction action)
{
// Shift+delete is handled via PlatformAction on macOS. this is not so useful in the context of a SearchTextBox
- // as we do not allow arrow key navigation in the first place (ie. the care should always be at the end of text)
+ // as we do not allow arrow key navigation in the first place (ie. the caret should always be at the end of text)
// Avoid handling it here to allow other components to potentially consume the shortcut.
if (action.ActionType == PlatformActionType.CharNext && action.ActionMethod == PlatformActionMethod.Delete)
return false;
diff --git a/osu.Game/Graphics/UserInterface/SeekLimitedSearchTextBox.cs b/osu.Game/Graphics/UserInterface/SeekLimitedSearchTextBox.cs
new file mode 100644
index 0000000000..6a9e8a5b8c
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/SeekLimitedSearchTextBox.cs
@@ -0,0 +1,13 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// A which does not handle left/right arrow keys for seeking.
+ ///
+ public class SeekLimitedSearchTextBox : SearchTextBox
+ {
+ public override bool HandleLeftRightArrows => false;
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
new file mode 100644
index 0000000000..4931a6aed6
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
@@ -0,0 +1,96 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics.Sprites;
+using osuTK;
+using osuTK.Graphics;
+using System.Collections.Generic;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ public class ShowMoreButton : LoadingButton
+ {
+ private const int duration = 200;
+
+ private Color4 chevronIconColour;
+
+ protected Color4 ChevronIconColour
+ {
+ get => chevronIconColour;
+ set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
+ }
+
+ public string Text
+ {
+ get => text.Text;
+ set => text.Text = value;
+ }
+
+ protected override IEnumerable EffectTargets => new[] { background };
+
+ private ChevronIcon leftChevron;
+ private ChevronIcon rightChevron;
+ private SpriteText text;
+ private Box background;
+ private FillFlowContainer textContainer;
+
+ public ShowMoreButton()
+ {
+ AutoSizeAxes = Axes.Both;
+ }
+
+ protected override Drawable CreateContent() => new CircularContainer
+ {
+ Masking = true,
+ Size = new Vector2(140, 30),
+ Children = new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ textContainer = new FillFlowContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7),
+ Children = new Drawable[]
+ {
+ leftChevron = new ChevronIcon(),
+ text = new OsuSpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
+ Text = "show more".ToUpper(),
+ },
+ rightChevron = new ChevronIcon(),
+ }
+ }
+ }
+ };
+
+ protected override void OnLoadStarted() => textContainer.FadeOut(duration, Easing.OutQuint);
+
+ protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
+
+ private class ChevronIcon : SpriteIcon
+ {
+ private const int icon_size = 8;
+
+ public ChevronIcon()
+ {
+ Anchor = Anchor.Centre;
+ Origin = Anchor.Centre;
+ Size = new Vector2(icon_size);
+ Icon = FontAwesome.Solid.ChevronDown;
+ }
+ }
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs
index 4717401c75..af03cbb63e 100644
--- a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs
+++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs
@@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Increment(int amount)
{
- Current.Value = Current.Value + amount;
+ Current.Value += amount;
}
}
}
diff --git a/osu.Game/Graphics/UserInterface/StatefulMenuItem.cs b/osu.Game/Graphics/UserInterface/StatefulMenuItem.cs
new file mode 100644
index 0000000000..0d7b36e51b
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/StatefulMenuItem.cs
@@ -0,0 +1,105 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics.Sprites;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// An which contains and displays a state.
+ ///
+ public abstract class StatefulMenuItem : OsuMenuItem
+ {
+ ///
+ /// The current state that should be displayed.
+ ///
+ public readonly Bindable State = new Bindable();
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// A function that mutates a state to another state after this is pressed.
+ /// The type of action which this performs.
+ protected StatefulMenuItem(string text, Func changeStateFunc, MenuItemType type = MenuItemType.Standard)
+ : this(text, changeStateFunc, type, null)
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// A function that mutates a state to another state after this is pressed.
+ /// The type of action which this performs.
+ /// A delegate to be invoked when this is pressed.
+ protected StatefulMenuItem(string text, Func changeStateFunc, MenuItemType type, Action action)
+ : base(text, type)
+ {
+ Action.Value = () =>
+ {
+ State.Value = changeStateFunc?.Invoke(State.Value) ?? State.Value;
+ action?.Invoke(State.Value);
+ };
+ }
+
+ ///
+ /// Retrieves the icon to be displayed for a state.
+ ///
+ /// The state to retrieve the relevant icon for.
+ /// The icon to be displayed for .
+ public abstract IconUsage? GetIconForState(object state);
+ }
+
+ public abstract class StatefulMenuItem : StatefulMenuItem
+ where T : struct
+ {
+ ///
+ /// The current state that should be displayed.
+ ///
+ public new readonly Bindable State = new Bindable();
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// A function that mutates a state to another state after this is pressed.
+ /// The type of action which this performs.
+ protected StatefulMenuItem(string text, Func changeStateFunc, MenuItemType type = MenuItemType.Standard)
+ : this(text, changeStateFunc, type, null)
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// A function that mutates a state to another state after this is pressed.
+ /// The type of action which this performs.
+ /// A delegate to be invoked when this is pressed.
+ protected StatefulMenuItem(string text, Func changeStateFunc, MenuItemType type, Action action)
+ : base(text, o => changeStateFunc?.Invoke((T)o) ?? o, type, o => action?.Invoke((T)o))
+ {
+ base.State.BindValueChanged(state =>
+ {
+ if (state.NewValue == null)
+ base.State.Value = default(T);
+
+ State.Value = (T)base.State.Value;
+ }, true);
+
+ State.BindValueChanged(state => base.State.Value = state.NewValue);
+ }
+
+ public sealed override IconUsage? GetIconForState(object state) => GetIconForState((T)state);
+
+ ///
+ /// Retrieves the icon to be displayed for a state.
+ ///
+ /// The state to retrieve the relevant icon for.
+ /// The icon to be displayed for .
+ public abstract IconUsage? GetIconForState(T state);
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/TernaryState.cs b/osu.Game/Graphics/UserInterface/TernaryState.cs
new file mode 100644
index 0000000000..d4de28044f
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/TernaryState.cs
@@ -0,0 +1,27 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// An on/off state with an extra indeterminate state.
+ ///
+ public enum TernaryState
+ {
+ ///
+ /// The current state is false.
+ ///
+ False,
+
+ ///
+ /// The current state is a combination of and .
+ /// The state becomes if the is pressed.
+ ///
+ Indeterminate,
+
+ ///
+ /// The current state is true.
+ ///
+ True
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/TernaryStateMenuItem.cs b/osu.Game/Graphics/UserInterface/TernaryStateMenuItem.cs
new file mode 100644
index 0000000000..2d9e2106d4
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/TernaryStateMenuItem.cs
@@ -0,0 +1,79 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Graphics.Sprites;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// An with three possible states.
+ ///
+ public class TernaryStateMenuItem : StatefulMenuItem
+ {
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// The type of action which this performs.
+ public TernaryStateMenuItem(string text, MenuItemType type = MenuItemType.Standard)
+ : this(text, type, null)
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// The type of action which this performs.
+ /// A delegate to be invoked when this is pressed.
+ public TernaryStateMenuItem(string text, MenuItemType type, Action action)
+ : this(text, getNextState, type, action)
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// A function that mutates a state to another state after this is pressed.
+ /// The type of action which this performs.
+ /// A delegate to be invoked when this is pressed.
+ protected TernaryStateMenuItem(string text, Func changeStateFunc, MenuItemType type, Action action)
+ : base(text, changeStateFunc, type, action)
+ {
+ }
+
+ public override IconUsage? GetIconForState(TernaryState state)
+ {
+ switch (state)
+ {
+ case TernaryState.Indeterminate:
+ return FontAwesome.Solid.DotCircle;
+
+ case TernaryState.True:
+ return FontAwesome.Solid.Check;
+ }
+
+ return null;
+ }
+
+ private static TernaryState getNextState(TernaryState state)
+ {
+ switch (state)
+ {
+ case TernaryState.False:
+ return TernaryState.True;
+
+ case TernaryState.Indeterminate:
+ return TernaryState.True;
+
+ case TernaryState.True:
+ return TernaryState.False;
+
+ default:
+ throw new ArgumentOutOfRangeException(nameof(state), state, null);
+ }
+ }
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/ToggleMenuItem.cs b/osu.Game/Graphics/UserInterface/ToggleMenuItem.cs
new file mode 100644
index 0000000000..f9ff9859dd
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/ToggleMenuItem.cs
@@ -0,0 +1,37 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Graphics.Sprites;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// An which displays an enabled or disabled state.
+ ///
+ public class ToggleMenuItem : StatefulMenuItem
+ {
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// The type of action which this performs.
+ public ToggleMenuItem(string text, MenuItemType type = MenuItemType.Standard)
+ : this(text, type, null)
+ {
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The text to display.
+ /// The type of action which this performs.
+ /// A delegate to be invoked when this is pressed.
+ public ToggleMenuItem(string text, MenuItemType type, Action action)
+ : base(text, value => !value, type, action)
+ {
+ }
+
+ public override IconUsage? GetIconForState(bool state) => state ? (IconUsage?)FontAwesome.Solid.Check : null;
+ }
+}
diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledComponent.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledComponent.cs
index 2e659825b7..1819b36667 100644
--- a/osu.Game/Graphics/UserInterfaceV2/LabelledComponent.cs
+++ b/osu.Game/Graphics/UserInterfaceV2/LabelledComponent.cs
@@ -1,132 +1,24 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Shapes;
-using osu.Game.Graphics.Containers;
-using osuTK;
+using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterfaceV2
{
- public abstract class LabelledComponent : CompositeDrawable
- where T : Drawable
+ public abstract class LabelledComponent : LabelledDrawable, IHasCurrentValue
+ where T : Drawable, IHasCurrentValue
{
- protected const float CONTENT_PADDING_VERTICAL = 10;
- protected const float CONTENT_PADDING_HORIZONTAL = 15;
- protected const float CORNER_RADIUS = 15;
-
- ///
- /// The component that is being displayed.
- ///
- protected readonly T Component;
-
- private readonly OsuTextFlowContainer labelText;
- private readonly OsuTextFlowContainer descriptionText;
-
- ///
- /// Creates a new .
- ///
- /// Whether the component should be padded or should be expanded to the bounds of this .
protected LabelledComponent(bool padded)
+ : base(padded)
{
- RelativeSizeAxes = Axes.X;
- AutoSizeAxes = Axes.Y;
-
- CornerRadius = CORNER_RADIUS;
- Masking = true;
-
- InternalChildren = new Drawable[]
- {
- new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = OsuColour.FromHex("1c2125"),
- },
- new FillFlowContainer
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical,
- Padding = padded
- ? new MarginPadding { Horizontal = CONTENT_PADDING_HORIZONTAL, Vertical = CONTENT_PADDING_VERTICAL }
- : new MarginPadding { Left = CONTENT_PADDING_HORIZONTAL },
- Spacing = new Vector2(0, 12),
- Children = new Drawable[]
- {
- new GridContainer
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Content = new[]
- {
- new Drawable[]
- {
- labelText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Bold))
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- AutoSizeAxes = Axes.Both,
- Padding = new MarginPadding { Right = 20 }
- },
- new Container
- {
- Anchor = Anchor.CentreRight,
- Origin = Anchor.CentreRight,
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Child = Component = CreateComponent().With(d =>
- {
- d.Anchor = Anchor.CentreRight;
- d.Origin = Anchor.CentreRight;
- })
- }
- },
- },
- RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
- ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
- },
- descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Padding = new MarginPadding { Bottom = padded ? 0 : CONTENT_PADDING_VERTICAL },
- Alpha = 0,
- }
- }
- }
- };
}
- [BackgroundDependencyLoader]
- private void load(OsuColour osuColour)
+ public Bindable Current
{
- descriptionText.Colour = osuColour.Yellow;
+ get => Component.Current;
+ set => Component.Current = value;
}
-
- public string Label
- {
- set => labelText.Text = value;
- }
-
- public string Description
- {
- set
- {
- descriptionText.Text = value;
-
- if (!string.IsNullOrEmpty(value))
- descriptionText.Show();
- else
- descriptionText.Hide();
- }
- }
-
- ///
- /// Creates the component that should be displayed.
- ///
- /// The component.
- protected abstract T CreateComponent();
}
}
diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs
new file mode 100644
index 0000000000..f44bd72aee
--- /dev/null
+++ b/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs
@@ -0,0 +1,132 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics.Containers;
+using osuTK;
+
+namespace osu.Game.Graphics.UserInterfaceV2
+{
+ public abstract class LabelledDrawable : CompositeDrawable
+ where T : Drawable
+ {
+ protected const float CONTENT_PADDING_VERTICAL = 10;
+ protected const float CONTENT_PADDING_HORIZONTAL = 15;
+ protected const float CORNER_RADIUS = 15;
+
+ ///
+ /// The component that is being displayed.
+ ///
+ protected readonly T Component;
+
+ private readonly OsuTextFlowContainer labelText;
+ private readonly OsuTextFlowContainer descriptionText;
+
+ ///
+ /// Creates a new .
+ ///
+ /// Whether the component should be padded or should be expanded to the bounds of this .
+ protected LabelledDrawable(bool padded)
+ {
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+
+ CornerRadius = CORNER_RADIUS;
+ Masking = true;
+
+ InternalChildren = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = OsuColour.FromHex("1c2125"),
+ },
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ Padding = padded
+ ? new MarginPadding { Horizontal = CONTENT_PADDING_HORIZONTAL, Vertical = CONTENT_PADDING_VERTICAL }
+ : new MarginPadding { Left = CONTENT_PADDING_HORIZONTAL },
+ Spacing = new Vector2(0, 12),
+ Children = new Drawable[]
+ {
+ new GridContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ labelText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Bold))
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ AutoSizeAxes = Axes.Both,
+ Padding = new MarginPadding { Right = 20 }
+ },
+ new Container
+ {
+ Anchor = Anchor.CentreRight,
+ Origin = Anchor.CentreRight,
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Child = Component = CreateComponent().With(d =>
+ {
+ d.Anchor = Anchor.CentreRight;
+ d.Origin = Anchor.CentreRight;
+ })
+ }
+ },
+ },
+ RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
+ ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
+ },
+ descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Padding = new MarginPadding { Bottom = padded ? 0 : CONTENT_PADDING_VERTICAL },
+ Alpha = 0,
+ }
+ }
+ }
+ };
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour osuColour)
+ {
+ descriptionText.Colour = osuColour.Yellow;
+ }
+
+ public string Label
+ {
+ set => labelText.Text = value;
+ }
+
+ public string Description
+ {
+ set
+ {
+ descriptionText.Text = value;
+
+ if (!string.IsNullOrEmpty(value))
+ descriptionText.Show();
+ else
+ descriptionText.Hide();
+ }
+ }
+
+ ///
+ /// Creates the component that should be displayed.
+ ///
+ /// The component.
+ protected abstract T CreateComponent();
+ }
+}
diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledSwitchButton.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledSwitchButton.cs
index c973f1d13e..c374d80830 100644
--- a/osu.Game/Graphics/UserInterfaceV2/LabelledSwitchButton.cs
+++ b/osu.Game/Graphics/UserInterfaceV2/LabelledSwitchButton.cs
@@ -3,7 +3,7 @@
namespace osu.Game.Graphics.UserInterfaceV2
{
- public class LabelledSwitchButton : LabelledComponent
+ public class LabelledSwitchButton : LabelledComponent
{
public LabelledSwitchButton()
: base(true)
diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledTextBox.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledTextBox.cs
index 50d2a14482..2cbe095d0b 100644
--- a/osu.Game/Graphics/UserInterfaceV2/LabelledTextBox.cs
+++ b/osu.Game/Graphics/UserInterfaceV2/LabelledTextBox.cs
@@ -8,7 +8,7 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterfaceV2
{
- public class LabelledTextBox : LabelledComponent
+ public class LabelledTextBox : LabelledComponent
{
public event TextBox.OnCommitHandler OnCommit;
diff --git a/osu.Game/IO/Archives/ZipArchiveReader.cs b/osu.Game/IO/Archives/ZipArchiveReader.cs
index 9033e7529d..35f38ea7e8 100644
--- a/osu.Game/IO/Archives/ZipArchiveReader.cs
+++ b/osu.Game/IO/Archives/ZipArchiveReader.cs
@@ -1,30 +1,16 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using osu.Framework.IO.Stores;
using SharpCompress.Archives.Zip;
-using SharpCompress.Common;
namespace osu.Game.IO.Archives
{
public sealed class ZipArchiveReader : ArchiveReader
{
- ///
- /// List of substrings that indicate a file should be ignored during the import process
- /// (usually due to representing no useful data and being autogenerated by the OS).
- ///
- private static readonly string[] filename_ignore_list =
- {
- // Mac-specific
- "__MACOSX",
- ".DS_Store",
- // Windows-specific
- "Thumbs.db"
- };
-
private readonly Stream archiveStream;
private readonly ZipArchive archive;
@@ -58,9 +44,7 @@ namespace osu.Game.IO.Archives
archiveStream.Dispose();
}
- private static bool canBeIgnored(IEntry entry) => filename_ignore_list.Any(ignoredName => entry.Key.IndexOf(ignoredName, StringComparison.OrdinalIgnoreCase) >= 0);
-
- public override IEnumerable Filenames => archive.Entries.Where(e => !canBeIgnored(e)).Select(e => e.Key).ToArray();
+ public override IEnumerable Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames();
public override Stream GetUnderlyingStream() => archiveStream;
}
diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs
index 7a84c11930..82b2c4be32 100644
--- a/osu.Game/IO/Legacy/SerializationReader.cs
+++ b/osu.Game/IO/Legacy/SerializationReader.cs
@@ -226,9 +226,7 @@ namespace osu.Game.IO.Legacy
public override Type BindToType(string assemblyName, string typeName)
{
- Type typeToDeserialize;
-
- if (cache.TryGetValue(assemblyName + typeName, out typeToDeserialize))
+ if (cache.TryGetValue(assemblyName + typeName, out var typeToDeserialize))
return typeToDeserialize;
List tmpTypes = new List();
diff --git a/osu.Game/Input/Bindings/DatabasedKeyBindingContainer.cs b/osu.Game/Input/Bindings/DatabasedKeyBindingContainer.cs
index f34b8f14b0..ea274284ac 100644
--- a/osu.Game/Input/Bindings/DatabasedKeyBindingContainer.cs
+++ b/osu.Game/Input/Bindings/DatabasedKeyBindingContainer.cs
@@ -30,7 +30,7 @@ namespace osu.Game.Input.Bindings
///
/// A reference to identify the current . Used to lookup mappings. Null for global mappings.
/// An optional variant for the specified . Used when a ruleset has more than one possible keyboard layouts.
- /// Specify how to deal with multiple matches of s and s.
+ /// Specify how to deal with multiple matches of s and s.
public DatabasedKeyBindingContainer(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
: base(simultaneousMode)
{
diff --git a/osu.Game/Input/KeyBindingStore.cs b/osu.Game/Input/KeyBindingStore.cs
index caddb1ae0d..74b3134964 100644
--- a/osu.Game/Input/KeyBindingStore.cs
+++ b/osu.Game/Input/KeyBindingStore.cs
@@ -46,6 +46,7 @@ namespace osu.Game.Input
continue;
foreach (var insertable in group.Skip(count).Take(aimCount - count))
+ {
// insert any defaults which are missing.
usage.Context.DatabasedKeyBinding.Add(new DatabasedKeyBinding
{
@@ -54,6 +55,7 @@ namespace osu.Game.Input
RulesetID = rulesetId,
Variant = variant
});
+ }
}
}
}
diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs
index d722c7a98a..1c45d26afd 100644
--- a/osu.Game/Online/API/APIAccess.cs
+++ b/osu.Game/Online/API/APIAccess.cs
@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading;
+using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@@ -198,6 +199,22 @@ namespace osu.Game.Online.API
}
}
+ public void Perform(APIRequest request)
+ {
+ try
+ {
+ request.Perform(this);
+ }
+ catch (Exception e)
+ {
+ // todo: fix exception handling
+ request.Fail(e);
+ }
+ }
+
+ public Task PerformAsync(APIRequest request) =>
+ Task.Factory.StartNew(() => Perform(request), TaskCreationOptions.LongRunning);
+
public void Login(string username, string password)
{
Debug.Assert(State == APIState.Offline);
@@ -227,7 +244,7 @@ namespace osu.Game.Online.API
{
try
{
- return JObject.Parse(req.ResponseString).SelectToken("form_error", true).ToObject();
+ return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).ToObject();
}
catch
{
diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs
index 4f613d5c3c..b424e0f086 100644
--- a/osu.Game/Online/API/APIRequest.cs
+++ b/osu.Game/Online/API/APIRequest.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using Newtonsoft.Json;
using osu.Framework.IO.Network;
using osu.Framework.Logging;
@@ -112,6 +113,22 @@ namespace osu.Game.Online.API
cancelled = true;
WebRequest?.Abort();
+ string responseString = WebRequest?.GetResponseString();
+
+ if (!string.IsNullOrEmpty(responseString))
+ {
+ try
+ {
+ // attempt to decode a displayable error string.
+ var error = JsonConvert.DeserializeObject(responseString);
+ if (error != null)
+ e = new Exception(error.ErrorMessage, e);
+ }
+ catch
+ {
+ }
+ }
+
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
pendingFailure = () => Failure?.Invoke(e);
checkAndScheduleFailure();
@@ -129,6 +146,12 @@ namespace osu.Game.Online.API
pendingFailure = null;
return true;
}
+
+ private class DisplayableError
+ {
+ [JsonProperty("error")]
+ public string ErrorMessage { get; set; }
+ }
}
public delegate void APIFailureHandler(Exception e);
diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs
index 6c04c77dc0..7f23f9b5d5 100644
--- a/osu.Game/Online/API/DummyAPIAccess.cs
+++ b/osu.Game/Online/API/DummyAPIAccess.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Threading;
+using System.Threading.Tasks;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Users;
@@ -19,7 +20,7 @@ namespace osu.Game.Online.API
public Bindable Activity { get; } = new Bindable();
- public bool IsLoggedIn => true;
+ public bool IsLoggedIn => State == APIState.Online;
public string ProvidedUsername => LocalUser.Value.Username;
@@ -56,6 +57,10 @@ namespace osu.Game.Online.API
{
}
+ public void Perform(APIRequest request) { }
+
+ public Task PerformAsync(APIRequest request) => Task.CompletedTask;
+
public void Register(IOnlineComponent component)
{
Scheduler.Add(delegate { components.Add(component); });
diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs
index 0cd41aee26..dff6d0b2ce 100644
--- a/osu.Game/Online/API/IAPIProvider.cs
+++ b/osu.Game/Online/API/IAPIProvider.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Threading.Tasks;
using osu.Framework.Bindables;
using osu.Game.Users;
@@ -42,6 +43,24 @@ namespace osu.Game.Online.API
/// The request to perform.
void Queue(APIRequest request);
+ ///
+ /// Perform a request immediately, bypassing any API state checks.
+ ///
+ ///
+ /// Can be used to run requests as a guest user.
+ ///
+ /// The request to perform.
+ void Perform(APIRequest request);
+
+ ///
+ /// Perform a request immediately, bypassing any API state checks.
+ ///
+ ///
+ /// Can be used to run requests as a guest user.
+ ///
+ /// The request to perform.
+ Task PerformAsync(APIRequest request);
+
///
/// Register a component to receive state changes.
///
diff --git a/osu.Game/Online/API/Requests/CommentVoteRequest.cs b/osu.Game/Online/API/Requests/CommentVoteRequest.cs
new file mode 100644
index 0000000000..06a3b1126e
--- /dev/null
+++ b/osu.Game/Online/API/Requests/CommentVoteRequest.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using osu.Game.Online.API.Requests.Responses;
+using System.Net.Http;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class CommentVoteRequest : APIRequest
+ {
+ private readonly long id;
+ private readonly CommentVoteAction action;
+
+ public CommentVoteRequest(long id, CommentVoteAction action)
+ {
+ this.id = id;
+ this.action = action;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+ req.Method = action == CommentVoteAction.Vote ? HttpMethod.Post : HttpMethod.Delete;
+ return req;
+ }
+
+ protected override string Target => $@"comments/{id}/vote";
+ }
+
+ public enum CommentVoteAction
+ {
+ Vote,
+ UnVote
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs
index b37a6804fe..87925b94c6 100644
--- a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs
+++ b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs
@@ -10,13 +10,11 @@ namespace osu.Game.Online.API.Requests
{
private readonly BeatmapInfo beatmap;
- private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}";
-
public GetBeatmapRequest(BeatmapInfo beatmap)
{
this.beatmap = beatmap;
}
- protected override string Target => $@"beatmaps/{lookupString}";
+ protected override string Target => $@"beatmaps/lookup?id={beatmap.OnlineBeatmapID}&checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path ?? string.Empty)}";
}
}
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
new file mode 100644
index 0000000000..7763501860
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -0,0 +1,47 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using Humanizer;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Overlays.Comments;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetCommentsRequest : APIRequest
+ {
+ private readonly long id;
+ private readonly int page;
+ private readonly CommentableType type;
+ private readonly CommentsSortCriteria sort;
+
+ public GetCommentsRequest(CommentableType type, long id, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1)
+ {
+ this.type = type;
+ this.sort = sort;
+ this.id = id;
+ this.page = page;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
+ req.AddParameter("commentable_id", id.ToString());
+ req.AddParameter("sort", sort.ToString().ToLowerInvariant());
+ req.AddParameter("page", page.ToString());
+
+ return req;
+ }
+
+ protected override string Target => "comments";
+ }
+
+ public enum CommentableType
+ {
+ Build,
+ Beatmapset,
+ NewsPost
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetCountriesResponse.cs b/osu.Game/Online/API/Requests/GetCountriesResponse.cs
new file mode 100644
index 0000000000..6624344b44
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetCountriesResponse.cs
@@ -0,0 +1,15 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using osu.Game.Users;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetCountriesResponse : ResponseWithCursor
+ {
+ [JsonProperty("ranking")]
+ public List Countries;
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs b/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs
new file mode 100644
index 0000000000..d8a1198627
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs
@@ -0,0 +1,17 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetCountryRankingsRequest : GetRankingsRequest
+ {
+ public GetCountryRankingsRequest(RulesetInfo ruleset, int page = 1)
+ : base(ruleset, page)
+ {
+ }
+
+ protected override string TargetPostfix() => "country";
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetRankingsRequest.cs b/osu.Game/Online/API/Requests/GetRankingsRequest.cs
new file mode 100644
index 0000000000..941691c4c1
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetRankingsRequest.cs
@@ -0,0 +1,33 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API.Requests
+{
+ public abstract class GetRankingsRequest : APIRequest
+ {
+ private readonly RulesetInfo ruleset;
+ private readonly int page;
+
+ protected GetRankingsRequest(RulesetInfo ruleset, int page = 1)
+ {
+ this.ruleset = ruleset;
+ this.page = page;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ req.AddParameter("page", page.ToString());
+
+ return req;
+ }
+
+ protected override string Target => $"rankings/{ruleset.ShortName}/{TargetPostfix()}";
+
+ protected abstract string TargetPostfix();
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetRoomScoresRequest.cs b/osu.Game/Online/API/Requests/GetRoomScoresRequest.cs
index 993e49dab2..eb53369d18 100644
--- a/osu.Game/Online/API/Requests/GetRoomScoresRequest.cs
+++ b/osu.Game/Online/API/Requests/GetRoomScoresRequest.cs
@@ -6,7 +6,7 @@ using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
- public class GetRoomScoresRequest : APIRequest>
+ public class GetRoomScoresRequest : APIRequest>
{
private readonly int roomId;
diff --git a/osu.Game/Online/API/Requests/GetScoresRequest.cs b/osu.Game/Online/API/Requests/GetScoresRequest.cs
index 50844fa256..bf3441d2a0 100644
--- a/osu.Game/Online/API/Requests/GetScoresRequest.cs
+++ b/osu.Game/Online/API/Requests/GetScoresRequest.cs
@@ -9,6 +9,7 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Mods;
using System.Text;
using System.Collections.Generic;
+using System.Diagnostics;
namespace osu.Game.Online.API.Requests
{
@@ -37,10 +38,12 @@ namespace osu.Game.Online.API.Requests
private void onSuccess(APILegacyScores r)
{
+ Debug.Assert(ruleset.ID != null, "ruleset.ID != null");
+
foreach (APILegacyScoreInfo score in r.Scores)
{
score.Beatmap = beatmap;
- score.Ruleset = ruleset;
+ score.OnlineRulesetID = ruleset.ID.Value;
}
var userScore = r.UserScore;
@@ -48,7 +51,7 @@ namespace osu.Game.Online.API.Requests
if (userScore != null)
{
userScore.Score.Beatmap = beatmap;
- userScore.Score.Ruleset = ruleset;
+ userScore.Score.OnlineRulesetID = ruleset.ID.Value;
}
}
diff --git a/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs b/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs
new file mode 100644
index 0000000000..9c3eba9fdc
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs
@@ -0,0 +1,39 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetUserRankingsRequest : GetRankingsRequest
+ {
+ private readonly string country;
+ private readonly UserRankingsType type;
+
+ public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, string country = null)
+ : base(ruleset, page)
+ {
+ this.type = type;
+ this.country = country;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ if (country != null)
+ req.AddParameter("country", country);
+
+ return req;
+ }
+
+ protected override string TargetPostfix() => type.ToString().ToLowerInvariant();
+ }
+
+ public enum UserRankingsType
+ {
+ Performance,
+ Score
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs b/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs
index 4908e5ecc2..123624d333 100644
--- a/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs
+++ b/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs
@@ -42,5 +42,6 @@ namespace osu.Game.Online.API.Requests
Ranked,
Approved,
Qualified,
+ Loved
}
}
diff --git a/osu.Game/Online/API/Requests/GetUsersResponse.cs b/osu.Game/Online/API/Requests/GetUsersResponse.cs
index 860785875a..b301f551e3 100644
--- a/osu.Game/Online/API/Requests/GetUsersResponse.cs
+++ b/osu.Game/Online/API/Requests/GetUsersResponse.cs
@@ -3,13 +3,13 @@
using System.Collections.Generic;
using Newtonsoft.Json;
-using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class GetUsersResponse : ResponseWithCursor
{
[JsonProperty("ranking")]
- public List Users;
+ public List Users;
}
}
diff --git a/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs b/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs
new file mode 100644
index 0000000000..f3724230cb
--- /dev/null
+++ b/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using System.Net.Http;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class PostBeatmapFavouriteRequest : APIRequest
+ {
+ private readonly int id;
+ private readonly BeatmapFavouriteAction action;
+
+ public PostBeatmapFavouriteRequest(int id, BeatmapFavouriteAction action)
+ {
+ this.id = id;
+ this.action = action;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+ req.Method = HttpMethod.Post;
+ req.AddParameter(@"action", action.ToString().ToLowerInvariant());
+ return req;
+ }
+
+ protected override string Target => $@"beatmapsets/{id}/favourites";
+ }
+
+ public enum BeatmapFavouriteAction
+ {
+ Favourite,
+ UnFavourite
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs
index 17da255873..b941cd8973 100644
--- a/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs
+++ b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs
@@ -5,56 +5,106 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests.Responses
{
- public class APILegacyScoreInfo : LegacyScoreInfo
+ public class APILegacyScoreInfo
{
- [JsonProperty(@"score")]
- private int totalScore
+ public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
{
- set => TotalScore = value;
+ var ruleset = rulesets.GetRuleset(OnlineRulesetID);
+
+ var mods = Mods != null ? ruleset.CreateInstance().GetAllMods().Where(mod => Mods.Contains(mod.Acronym)).ToArray() : Array.Empty();
+
+ var scoreInfo = new ScoreInfo
+ {
+ TotalScore = TotalScore,
+ MaxCombo = MaxCombo,
+ User = User,
+ Accuracy = Accuracy,
+ OnlineScoreID = OnlineScoreID,
+ Date = Date,
+ PP = PP,
+ Beatmap = Beatmap,
+ RulesetID = OnlineRulesetID,
+ Hash = Replay ? "online" : string.Empty, // todo: temporary?
+ Rank = Rank,
+ Ruleset = ruleset,
+ Mods = mods,
+ };
+
+ if (Statistics != null)
+ {
+ foreach (var kvp in Statistics)
+ {
+ switch (kvp.Key)
+ {
+ case @"count_geki":
+ scoreInfo.SetCountGeki(kvp.Value);
+ break;
+
+ case @"count_300":
+ scoreInfo.SetCount300(kvp.Value);
+ break;
+
+ case @"count_katu":
+ scoreInfo.SetCountKatu(kvp.Value);
+ break;
+
+ case @"count_100":
+ scoreInfo.SetCount100(kvp.Value);
+ break;
+
+ case @"count_50":
+ scoreInfo.SetCount50(kvp.Value);
+ break;
+
+ case @"count_miss":
+ scoreInfo.SetCountMiss(kvp.Value);
+ break;
+ }
+ }
+ }
+
+ return scoreInfo;
}
+ [JsonProperty(@"score")]
+ public int TotalScore { get; set; }
+
[JsonProperty(@"max_combo")]
- private int maxCombo
- {
- set => MaxCombo = value;
- }
+ public int MaxCombo { get; set; }
[JsonProperty(@"user")]
- private User user
- {
- set => User = value;
- }
+ public User User { get; set; }
[JsonProperty(@"id")]
- private long onlineScoreID
- {
- set => OnlineScoreID = value;
- }
+ public long OnlineScoreID { get; set; }
[JsonProperty(@"replay")]
public bool Replay { get; set; }
[JsonProperty(@"created_at")]
- private DateTimeOffset date
- {
- set => Date = value;
- }
+ public DateTimeOffset Date { get; set; }
[JsonProperty(@"beatmap")]
- private BeatmapInfo beatmap
- {
- set => Beatmap = value;
- }
+ public BeatmapInfo Beatmap { get; set; }
+
+ [JsonProperty("accuracy")]
+ public double Accuracy { get; set; }
+
+ [JsonProperty(@"pp")]
+ public double? PP { get; set; }
[JsonProperty(@"beatmapset")]
- private BeatmapMetadata metadata
+ public BeatmapMetadata Metadata
{
set
{
@@ -67,68 +117,16 @@ namespace osu.Game.Online.API.Requests.Responses
}
[JsonProperty(@"statistics")]
- private Dictionary jsonStats
- {
- set
- {
- foreach (var kvp in value)
- {
- switch (kvp.Key)
- {
- case @"count_geki":
- CountGeki = kvp.Value;
- break;
-
- case @"count_300":
- Count300 = kvp.Value;
- break;
-
- case @"count_katu":
- CountKatu = kvp.Value;
- break;
-
- case @"count_100":
- Count100 = kvp.Value;
- break;
-
- case @"count_50":
- Count50 = kvp.Value;
- break;
-
- case @"count_miss":
- CountMiss = kvp.Value;
- break;
-
- default:
- continue;
- }
- }
- }
- }
+ public Dictionary Statistics { get; set; }
[JsonProperty(@"mode_int")]
- public int OnlineRulesetID
- {
- get => RulesetID;
- set => RulesetID = value;
- }
+ public int OnlineRulesetID { get; set; }
[JsonProperty(@"mods")]
- private string[] modStrings { get; set; }
+ public string[] Mods { get; set; }
- public override RulesetInfo Ruleset
- {
- get => base.Ruleset;
- set
- {
- base.Ruleset = value;
-
- if (modStrings != null)
- {
- // Evaluate the mod string
- Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.Acronym)).ToArray();
- }
- }
- }
+ [JsonProperty("rank")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public ScoreRank Rank { get; set; }
}
}
diff --git a/osu.Game/Online/API/Requests/Responses/APIRoomScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APIRoomScoreInfo.cs
deleted file mode 100644
index 33467b59b2..0000000000
--- a/osu.Game/Online/API/Requests/Responses/APIRoomScoreInfo.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using Newtonsoft.Json;
-using osu.Game.Scoring;
-
-namespace osu.Game.Online.API.Requests.Responses
-{
- public class APIRoomScoreInfo : ScoreInfo
- {
- [JsonProperty("attempts")]
- public int TotalAttempts { get; set; }
-
- [JsonProperty("completed")]
- public int CompletedBeatmaps { get; set; }
- }
-}
diff --git a/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs b/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs
new file mode 100644
index 0000000000..0bba6a93bd
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/APIUserScoreAggregate.cs
@@ -0,0 +1,45 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Scoring;
+using osu.Game.Users;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class APIUserScoreAggregate
+ {
+ [JsonProperty("attempts")]
+ public int TotalAttempts { get; set; }
+
+ [JsonProperty("completed")]
+ public int CompletedBeatmaps { get; set; }
+
+ [JsonProperty("accuracy")]
+ public double Accuracy { get; set; }
+
+ [JsonProperty(@"pp")]
+ public double? PP { get; set; }
+
+ [JsonProperty(@"room_id")]
+ public int RoomID { get; set; }
+
+ [JsonProperty("total_score")]
+ public long TotalScore { get; set; }
+
+ [JsonProperty(@"user_id")]
+ public long UserID { get; set; }
+
+ [JsonProperty("user")]
+ public User User { get; set; }
+
+ public ScoreInfo CreateScoreInfo() =>
+ new ScoreInfo
+ {
+ Accuracy = Accuracy,
+ PP = PP,
+ TotalScore = TotalScore,
+ User = User,
+ };
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
new file mode 100644
index 0000000000..5510e9afff
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -0,0 +1,81 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Users;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text.RegularExpressions;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class Comment
+ {
+ [JsonProperty(@"id")]
+ public long Id { get; set; }
+
+ [JsonProperty(@"parent_id")]
+ public long? ParentId { get; set; }
+
+ public readonly List ChildComments = new List();
+
+ public Comment ParentComment { get; set; }
+
+ [JsonProperty(@"user_id")]
+ public long? UserId { get; set; }
+
+ public User User { get; set; }
+
+ [JsonProperty(@"message")]
+ public string Message { get; set; }
+
+ [JsonProperty(@"message_html")]
+ public string MessageHtml { get; set; }
+
+ [JsonProperty(@"replies_count")]
+ public int RepliesCount { get; set; }
+
+ [JsonProperty(@"votes_count")]
+ public int VotesCount { get; set; }
+
+ [JsonProperty(@"commenatble_type")]
+ public string CommentableType { get; set; }
+
+ [JsonProperty(@"commentable_id")]
+ public int CommentableId { get; set; }
+
+ [JsonProperty(@"legacy_name")]
+ public string LegacyName { get; set; }
+
+ [JsonProperty(@"created_at")]
+ public DateTimeOffset CreatedAt { get; set; }
+
+ [JsonProperty(@"updated_at")]
+ public DateTimeOffset? UpdatedAt { get; set; }
+
+ [JsonProperty(@"deleted_at")]
+ public DateTimeOffset? DeletedAt { get; set; }
+
+ [JsonProperty(@"edited_at")]
+ public DateTimeOffset? EditedAt { get; set; }
+
+ [JsonProperty(@"edited_by_id")]
+ public long? EditedById { get; set; }
+
+ public User EditedUser { get; set; }
+
+ public bool IsTopLevel => !ParentId.HasValue;
+
+ public bool IsDeleted => DeletedAt.HasValue;
+
+ public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
+
+ public bool IsVoted { get; set; }
+
+ public string GetMessage => HasMessage ? WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)) : string.Empty;
+
+ public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/CommentBundle.cs b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs
new file mode 100644
index 0000000000..8db5d8d6ad
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs
@@ -0,0 +1,93 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Users;
+using System.Collections.Generic;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class CommentBundle
+ {
+ private List comments;
+
+ [JsonProperty(@"comments")]
+ public List Comments
+ {
+ get => comments;
+ set
+ {
+ comments = value;
+ comments.ForEach(child =>
+ {
+ if (child.ParentId != null)
+ {
+ comments.ForEach(parent =>
+ {
+ if (parent.Id == child.ParentId)
+ {
+ parent.ChildComments.Add(child);
+ child.ParentComment = parent;
+ }
+ });
+ }
+ });
+ }
+ }
+
+ [JsonProperty(@"has_more")]
+ public bool HasMore { get; set; }
+
+ [JsonProperty(@"has_more_id")]
+ public long? HasMoreId { get; set; }
+
+ [JsonProperty(@"user_follow")]
+ public bool UserFollow { get; set; }
+
+ [JsonProperty(@"included_comments")]
+ public List IncludedComments { get; set; }
+
+ [JsonProperty(@"user_votes")]
+ private List userVotes
+ {
+ set => value.ForEach(v =>
+ {
+ Comments.ForEach(c =>
+ {
+ if (v == c.Id)
+ c.IsVoted = true;
+ });
+ });
+ }
+
+ private List users;
+
+ [JsonProperty(@"users")]
+ public List Users
+ {
+ get => users;
+ set
+ {
+ users = value;
+
+ value.ForEach(u =>
+ {
+ Comments.ForEach(c =>
+ {
+ if (c.UserId == u.Id)
+ c.User = u;
+
+ if (c.EditedById == u.Id)
+ c.EditedUser = u;
+ });
+ });
+ }
+ }
+
+ [JsonProperty(@"total")]
+ public int Total { get; set; }
+
+ [JsonProperty(@"top_level_count")]
+ public int TopLevelCount { get; set; }
+ }
+}
diff --git a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
index c8c36789c4..5652b8d2bd 100644
--- a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
+++ b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Online.API.Requests
public SearchBeatmapSetsRequest(string query, RulesetInfo ruleset, BeatmapSearchCategory searchCategory = BeatmapSearchCategory.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending)
{
- this.query = System.Uri.EscapeDataString(query);
+ this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
this.ruleset = ruleset;
this.searchCategory = searchCategory;
this.sortCriteria = sortCriteria;
diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs
index 9ec39c5cb1..451174a73c 100644
--- a/osu.Game/Online/Chat/Channel.cs
+++ b/osu.Game/Online/Chat/Channel.cs
@@ -14,7 +14,7 @@ namespace osu.Game.Online.Chat
{
public class Channel
{
- public readonly int MaxHistory = 300;
+ public const int MAX_HISTORY = 300;
///
/// Contains every joined user except the current logged in user. Currently only returned for PM channels.
@@ -80,8 +80,6 @@ namespace osu.Game.Online.Chat
///
public Bindable Joined = new Bindable();
- public const int MAX_HISTORY = 300;
-
[JsonConstructor]
public Channel()
{
@@ -162,8 +160,8 @@ namespace osu.Game.Online.Chat
{
// never purge local echos
int messageCount = Messages.Count - pendingMessages.Count;
- if (messageCount > MaxHistory)
- Messages.RemoveRange(0, messageCount - MaxHistory);
+ if (messageCount > MAX_HISTORY)
+ Messages.RemoveRange(0, messageCount - MAX_HISTORY);
}
}
}
diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs
index 4f6066cab1..1d8c5609d9 100644
--- a/osu.Game/Online/Chat/ChannelManager.cs
+++ b/osu.Game/Online/Chat/ChannelManager.cs
@@ -220,7 +220,7 @@ namespace osu.Game.Online.Chat
break;
}
- var channel = availableChannels.Where(c => c.Name == content || c.Name == $"#{content}").FirstOrDefault();
+ var channel = availableChannels.FirstOrDefault(c => c.Name == content || c.Name == $"#{content}");
if (channel == null)
{
diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs
index 24d17612ee..717de18c14 100644
--- a/osu.Game/Online/Chat/MessageFormatter.cs
+++ b/osu.Game/Online/Chat/MessageFormatter.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Online.Chat
private static readonly Regex new_link_regex = new Regex(@"\[(?[a-z]+://[^ ]+) (?(((?<=\\)[\[\]])|[^\[\]])*(((?\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]");
// [test](https://osu.ppy.sh/b/1234) -> test (https://osu.ppy.sh/b/1234) aka correct markdown format
- private static readonly Regex markdown_link_regex = new Regex(@"\[(?(((?<=\\)[\[\]])|[^\[\]])*(((?\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]\((?[a-z]+://[^ ]+)\)");
+ private static readonly Regex markdown_link_regex = new Regex(@"\[(?(((?<=\\)[\[\]])|[^\[\]])*(((?\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]\((?[a-z]+://[^ ]+)(\s+(?""([^""]|(?<=\\)"")*""))?\)");
// advanced, RFC-compatible regular expression that matches any possible URL, *but* allows certain invalid characters that are widely used
// This is in the format (, [optional]):
@@ -81,7 +81,7 @@ namespace osu.Game.Online.Chat
//since we just changed the line display text, offset any already processed links.
result.Links.ForEach(l => l.Index -= l.Index > index ? m.Length - displayText.Length : 0);
- var details = getLinkDetails(linkText);
+ var details = GetLinkDetails(linkText);
result.Links.Add(new Link(linkText, index, displayText.Length, linkActionOverride ?? details.Action, details.Argument));
//adjust the offset for processing the current matches group.
@@ -95,15 +95,21 @@ namespace osu.Game.Online.Chat
foreach (Match m in regex.Matches(result.Text, startIndex))
{
var index = m.Index;
- var link = m.Groups["link"].Value;
- var indexLength = link.Length;
+ var linkText = m.Groups["link"].Value;
+ var indexLength = linkText.Length;
- var details = getLinkDetails(link);
- result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
+ var details = GetLinkDetails(linkText);
+ var link = new Link(linkText, index, indexLength, details.Action, details.Argument);
+
+ // sometimes an already-processed formatted link can reduce to a simple URL, too
+ // (example: [mean example - https://osu.ppy.sh](https://osu.ppy.sh))
+ // therefore we need to check if any of the pre-existing links contains the raw one we found
+ if (result.Links.All(existingLink => !existingLink.Overlaps(link)))
+ result.Links.Add(link);
}
}
- private static LinkDetails getLinkDetails(string url)
+ public static LinkDetails GetLinkDetails(string url)
{
var args = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
args[0] = args[0].TrimEnd(':');
@@ -249,17 +255,17 @@ namespace osu.Game.Online.Chat
OriginalText = Text = text;
}
}
+ }
- public class LinkDetails
+ public class LinkDetails
+ {
+ public LinkAction Action;
+ public string Argument;
+
+ public LinkDetails(LinkAction action, string argument)
{
- public LinkAction Action;
- public string Argument;
-
- public LinkDetails(LinkAction action, string argument)
- {
- Action = action;
- Argument = argument;
- }
+ Action = action;
+ Argument = argument;
}
}
@@ -273,6 +279,7 @@ namespace osu.Game.Online.Chat
JoinMultiplayerMatch,
Spectate,
OpenUserProfile,
+ Custom
}
public class Link : IComparable
@@ -292,6 +299,8 @@ namespace osu.Game.Online.Chat
Argument = argument;
}
+ public bool Overlaps(Link otherLink) => Index < otherLink.Index + otherLink.Length && otherLink.Index < Index + Length;
+
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
}
}
diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs
index 8f39fb9006..21d0bcc4bf 100644
--- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs
+++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs
@@ -8,6 +8,7 @@ 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.UserInterface;
using osu.Game.Overlays.Chat;
using osuTK.Graphics;
@@ -124,6 +125,8 @@ namespace osu.Game.Online.Chat
protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m);
+ protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new CustomDaySeparator(time);
+
public StandAloneDrawableChannel(Channel channel)
: base(channel)
{
@@ -134,6 +137,24 @@ namespace osu.Game.Online.Chat
{
ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 };
}
+
+ private class CustomDaySeparator : DaySeparator
+ {
+ public CustomDaySeparator(DateTimeOffset time)
+ : base(time)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ Colour = colours.Yellow;
+ TextSize = 14;
+ LineHeight = 1;
+ Padding = new MarginPadding { Horizontal = 10 };
+ Margin = new MarginPadding { Vertical = 5 };
+ }
+ }
}
protected class StandAloneMessage : ChatLine
diff --git a/osu.Game/Online/DownloadTrackingComposite.cs b/osu.Game/Online/DownloadTrackingComposite.cs
index 7bfdc7ff69..9a0e112727 100644
--- a/osu.Game/Online/DownloadTrackingComposite.cs
+++ b/osu.Game/Online/DownloadTrackingComposite.cs
@@ -11,7 +11,7 @@ using osu.Game.Online.API;
namespace osu.Game.Online
{
///
- /// A component which tracks a