├── .github ├── FUNDING.yml └── workflows │ ├── CD.yml │ └── CI.yml ├── .gitignore ├── .screenshots ├── beatmap.png └── list.png ├── Changelog.md ├── Directory.Build.props ├── License.txt ├── OsuHelper.Tests ├── Logic │ └── BeatmapTraitsLogicTests.cs └── OsuHelper.Tests.csproj ├── OsuHelper.sln ├── OsuHelper.sln.DotSettings ├── OsuHelper ├── App.xaml ├── App.xaml.cs ├── Bootstrapper.cs ├── Converters │ ├── ModsToStringConverter.cs │ └── TimeSpanToShortStringConverter.cs ├── Exceptions │ ├── HttpErrorStatusCodeException.cs │ └── RecommendationsUnavailableException.cs ├── FodyWeavers.xml ├── FodyWeavers.xsd ├── Internal │ ├── Extensions.cs │ └── ProcessEx.cs ├── Logic │ ├── BeatmapTraitsLogic.cs │ └── Extensions.cs ├── Models │ ├── Beatmap.cs │ ├── BeatmapRankingStatus.cs │ ├── BeatmapTraits.cs │ ├── Extensions.cs │ ├── GameMode.cs │ ├── Mods.cs │ ├── Play.cs │ ├── PlayRank.cs │ └── Recommendation.cs ├── OsuHelper.csproj ├── Services │ ├── AudioService.cs │ ├── CacheService.cs │ ├── DataService.cs │ ├── RecommendationService.cs │ ├── SettingsService.cs │ └── UpdateService.cs ├── ViewModels │ ├── Dialogs │ │ ├── BeatmapDetailsViewModel.cs │ │ └── SettingsViewModel.cs │ ├── Framework │ │ ├── DialogManager.cs │ │ ├── DialogScreen.cs │ │ ├── Extensions.cs │ │ └── IViewModelFactory.cs │ └── RootViewModel.cs ├── Views │ ├── Dialogs │ │ ├── BeatmapDetailsView.xaml │ │ ├── BeatmapDetailsView.xaml.cs │ │ ├── SettingsView.xaml │ │ └── SettingsView.xaml.cs │ ├── RootView.xaml │ └── RootView.xaml.cs └── favicon.ico └── ReadMe.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Tyrrrz 2 | patreon: Tyrrrz 3 | custom: ['buymeacoffee.com/Tyrrrz', 'tyrrrz.me/donate'] -------------------------------------------------------------------------------- /.github/workflows/CD.yml: -------------------------------------------------------------------------------- 1 | name: CD 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | build: 10 | runs-on: windows-latest 11 | 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2.3.3 15 | 16 | - name: Install .NET 17 | uses: actions/setup-dotnet@v1.7.2 18 | with: 19 | dotnet-version: 6.0.x 20 | 21 | - name: Clean 22 | run: dotnet clean OsuHelper.sln && dotnet nuget locals all --clear 23 | 24 | - name: Build & publish 25 | run: dotnet publish OsuHelper/ -o OsuHelper/bin/Publish/ --configuration Release 26 | 27 | - name: Pack 28 | run: Compress-Archive -Path OsuHelper/bin/Publish/* -DestinationPath OsuHelper/bin/Publish/Archive.zip -Force 29 | shell: pwsh 30 | 31 | - name: Create release 32 | id: create_release 33 | uses: actions/create-release@v1.0.1 34 | env: 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | with: 37 | tag_name: ${{ github.ref }} 38 | release_name: ${{ github.ref }} 39 | body: | 40 | [Changelog](https://github.com/Tyrrrz/OsuHelper/blob/master/Changelog.md) 41 | draft: false 42 | prerelease: false 43 | 44 | - name: Upload release asset 45 | uses: actions/upload-release-asset@v1.0.2 46 | env: 47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 48 | with: 49 | upload_url: ${{ steps.create_release.outputs.upload_url }} 50 | asset_path: OsuHelper/bin/Publish/Archive.zip 51 | asset_name: OsuHelper.zip 52 | asset_content_type: application/zip -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: windows-latest 8 | 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2.3.3 12 | 13 | - name: Install .NET 14 | uses: actions/setup-dotnet@v1.7.2 15 | with: 16 | dotnet-version: 6.0.x 17 | 18 | - name: Clean 19 | run: dotnet clean OsuHelper.sln && dotnet nuget locals all --clear 20 | 21 | - name: Build & test 22 | run: dotnet test -c Release -l GitHubActions 23 | 24 | - name: Build & publish 25 | run: dotnet publish OsuHelper/ -o OsuHelper/bin/Publish/ --configuration Release 26 | 27 | - name: Upload build artifacts 28 | uses: actions/upload-artifact@v1 29 | with: 30 | name: OsuHelper 31 | path: OsuHelper/bin/Publish/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific files 2 | *.suo 3 | *.user 4 | *.userosscache 5 | *.sln.docstates 6 | .idea/ 7 | 8 | # Build results 9 | [Dd]ebug/ 10 | [Dd]ebugPublic/ 11 | [Rr]elease/ 12 | [Rr]eleases/ 13 | [Xx]64/ 14 | [Xx]86/ 15 | [Bb]uild/ 16 | bld/ 17 | [Bb]in/ 18 | [Oo]bj/ 19 | 20 | # Coverage 21 | *.opencover.xml -------------------------------------------------------------------------------- /.screenshots/beatmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tyrrrz/OsuHelper/b2dfa895272e1d58780eab84097afeac50ddf4f1/.screenshots/beatmap.png -------------------------------------------------------------------------------- /.screenshots/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tyrrrz/OsuHelper/b2dfa895272e1d58780eab84097afeac50ddf4f1/.screenshots/list.png -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | ### v2.4 (18-Feb-2022) 2 | 3 | - Migrated to .NET 6. 4 | - Added bootstrapper that installs application dependencies automatically. 5 | 6 | Note: This is _definitely_ the final release of osu!helper. 7 | 8 | ### v2.3 (19-Dec-2020) 9 | 10 | - Migrated to .NET Core 3.1. 11 | - Fixed a few minor issues. 12 | 13 | Note: This is the final release of osu!helper. No future development is expected. 14 | 15 | ### v2.2 (30-Nov-2019) 16 | 17 | - Migrated to .NET Core 3.0. You will need to install .NET Core runtime in order to run this application starting from this version. You can download it [here](https://dotnet.microsoft.com/download/dotnet-core/3.0/runtime). 18 | - Fixed an issue where map traits were incorrectly calculated with doubletime and halftime mods. 19 | 20 | ### v2.1.1 (17-Jul-2019) 21 | 22 | - Updated the URL that opens when you click "Generate API key" in the settings dialog. 23 | - Updated visual style of scrollbars. 24 | 25 | ### v2.1 (07-May-2019) 26 | 27 | - Improved button layout on the beatmap details popup. Removed "close" button, dialog now closes on click away. Removed "open page" button, clicking beatmap title will now open its page. Pulled alternative download options from context menu to separate buttons, for easier access. 28 | - Updated some links to point to the new osu! website. 29 | 30 | ### v2.0.3 (11-Apr-2019) 31 | 32 | - Improved render quality of beatmap images. 33 | - Current progress is now also shown in the taskbar. 34 | - Fixed an issue where popup dialog would sometimes appear over other windows. 35 | 36 | ### v2.0.2 (15-Apr-2018) 37 | 38 | - Implemented application auto-update (can be disabled in settings). 39 | 40 | ### v2.0.1 (31-Dec-2017) 41 | 42 | - Fixed a crash when trying to preview a beatmap that doesn't allow previewing for non-logged in users. 43 | - Fixed occasional crashes due to osu! API not responding properly under high request rates. 44 | 45 | ### v2.0 (30-Dec-2017) 46 | 47 | - **The entire application was re-developed from scratch.** 48 | - Reworked the UI to provide a more streamlined experience. 49 | - Stopped using `oppai` for PP and map difficulty calculation. 50 | - Increased size of data batches processed by recommendation service. 51 | - Improved recommendation logic and its performance. 52 | - Added some minor new features. 53 | - Fixed numerous bugs. -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0-windows 5 | 2.4 6 | Tyrrrz 7 | Copyright (C) Oleksii Holub 8 | preview 9 | enable 10 | nullable 11 | 12 | 13 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | OsuHelper 2 | Copyright (C) 2016-2022 Oleksii Holub 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | ====================================================================== 18 | 19 | GNU GENERAL PUBLIC LICENSE 20 | Version 3, 29 June 2007 21 | 22 | Copyright (C) 2007 Free Software Foundation, Inc. 23 | Everyone is permitted to copy and distribute verbatim copies 24 | of this license document, but changing it is not allowed. 25 | 26 | Preamble 27 | 28 | The GNU General Public License is a free, copyleft license for 29 | software and other kinds of works. 30 | 31 | The licenses for most software and other practical works are designed 32 | to take away your freedom to share and change the works. By contrast, 33 | the GNU General Public License is intended to guarantee your freedom to 34 | share and change all versions of a program--to make sure it remains free 35 | software for all its users. We, the Free Software Foundation, use the 36 | GNU General Public License for most of our software; it applies also to 37 | any other work released this way by its authors. You can apply it to 38 | your programs, too. 39 | 40 | When we speak of free software, we are referring to freedom, not 41 | price. Our General Public Licenses are designed to make sure that you 42 | have the freedom to distribute copies of free software (and charge for 43 | them if you wish), that you receive source code or can get it if you 44 | want it, that you can change the software or use pieces of it in new 45 | free programs, and that you know you can do these things. 46 | 47 | To protect your rights, we need to prevent others from denying you 48 | these rights or asking you to surrender the rights. Therefore, you have 49 | certain responsibilities if you distribute copies of the software, or if 50 | you modify it: responsibilities to respect the freedom of others. 51 | 52 | For example, if you distribute copies of such a program, whether 53 | gratis or for a fee, you must pass on to the recipients the same 54 | freedoms that you received. You must make sure that they, too, receive 55 | or can get the source code. And you must show them these terms so they 56 | know their rights. 57 | 58 | Developers that use the GNU GPL protect your rights with two steps: 59 | (1) assert copyright on the software, and (2) offer you this License 60 | giving you legal permission to copy, distribute and/or modify it. 61 | 62 | For the developers' and authors' protection, the GPL clearly explains 63 | that there is no warranty for this free software. For both users' and 64 | authors' sake, the GPL requires that modified versions be marked as 65 | changed, so that their problems will not be attributed erroneously to 66 | authors of previous versions. 67 | 68 | Some devices are designed to deny users access to install or run 69 | modified versions of the software inside them, although the manufacturer 70 | can do so. This is fundamentally incompatible with the aim of 71 | protecting users' freedom to change the software. The systematic 72 | pattern of such abuse occurs in the area of products for individuals to 73 | use, which is precisely where it is most unacceptable. Therefore, we 74 | have designed this version of the GPL to prohibit the practice for those 75 | products. If such problems arise substantially in other domains, we 76 | stand ready to extend this provision to those domains in future versions 77 | of the GPL, as needed to protect the freedom of users. 78 | 79 | Finally, every program is threatened constantly by software patents. 80 | States should not allow patents to restrict development and use of 81 | software on general-purpose computers, but in those that do, we wish to 82 | avoid the special danger that patents applied to a free program could 83 | make it effectively proprietary. To prevent this, the GPL assures that 84 | patents cannot be used to render the program non-free. 85 | 86 | The precise terms and conditions for copying, distribution and 87 | modification follow. 88 | 89 | TERMS AND CONDITIONS 90 | 91 | 0. Definitions. 92 | 93 | "This License" refers to version 3 of the GNU General Public License. 94 | 95 | "Copyright" also means copyright-like laws that apply to other kinds of 96 | works, such as semiconductor masks. 97 | 98 | "The Program" refers to any copyrightable work licensed under this 99 | License. Each licensee is addressed as "you". "Licensees" and 100 | "recipients" may be individuals or organizations. 101 | 102 | To "modify" a work means to copy from or adapt all or part of the work 103 | in a fashion requiring copyright permission, other than the making of an 104 | exact copy. The resulting work is called a "modified version" of the 105 | earlier work or a work "based on" the earlier work. 106 | 107 | A "covered work" means either the unmodified Program or a work based 108 | on the Program. 109 | 110 | To "propagate" a work means to do anything with it that, without 111 | permission, would make you directly or secondarily liable for 112 | infringement under applicable copyright law, except executing it on a 113 | computer or modifying a private copy. Propagation includes copying, 114 | distribution (with or without modification), making available to the 115 | public, and in some countries other activities as well. 116 | 117 | To "convey" a work means any kind of propagation that enables other 118 | parties to make or receive copies. Mere interaction with a user through 119 | a computer network, with no transfer of a copy, is not conveying. 120 | 121 | An interactive user interface displays "Appropriate Legal Notices" 122 | to the extent that it includes a convenient and prominently visible 123 | feature that (1) displays an appropriate copyright notice, and (2) 124 | tells the user that there is no warranty for the work (except to the 125 | extent that warranties are provided), that licensees may convey the 126 | work under this License, and how to view a copy of this License. If 127 | the interface presents a list of user commands or options, such as a 128 | menu, a prominent item in the list meets this criterion. 129 | 130 | 1. Source Code. 131 | 132 | The "source code" for a work means the preferred form of the work 133 | for making modifications to it. "Object code" means any non-source 134 | form of a work. 135 | 136 | A "Standard Interface" means an interface that either is an official 137 | standard defined by a recognized standards body, or, in the case of 138 | interfaces specified for a particular programming language, one that 139 | is widely used among developers working in that language. 140 | 141 | The "System Libraries" of an executable work include anything, other 142 | than the work as a whole, that (a) is included in the normal form of 143 | packaging a Major Component, but which is not part of that Major 144 | Component, and (b) serves only to enable use of the work with that 145 | Major Component, or to implement a Standard Interface for which an 146 | implementation is available to the public in source code form. A 147 | "Major Component", in this context, means a major essential component 148 | (kernel, window system, and so on) of the specific operating system 149 | (if any) on which the executable work runs, or a compiler used to 150 | produce the work, or an object code interpreter used to run it. 151 | 152 | The "Corresponding Source" for a work in object code form means all 153 | the source code needed to generate, install, and (for an executable 154 | work) run the object code and to modify the work, including scripts to 155 | control those activities. However, it does not include the work's 156 | System Libraries, or general-purpose tools or generally available free 157 | programs which are used unmodified in performing those activities but 158 | which are not part of the work. For example, Corresponding Source 159 | includes interface definition files associated with source files for 160 | the work, and the source code for shared libraries and dynamically 161 | linked subprograms that the work is specifically designed to require, 162 | such as by intimate data communication or control flow between those 163 | subprograms and other parts of the work. 164 | 165 | The Corresponding Source need not include anything that users 166 | can regenerate automatically from other parts of the Corresponding 167 | Source. 168 | 169 | The Corresponding Source for a work in source code form is that 170 | same work. 171 | 172 | 2. Basic Permissions. 173 | 174 | All rights granted under this License are granted for the term of 175 | copyright on the Program, and are irrevocable provided the stated 176 | conditions are met. This License explicitly affirms your unlimited 177 | permission to run the unmodified Program. The output from running a 178 | covered work is covered by this License only if the output, given its 179 | content, constitutes a covered work. This License acknowledges your 180 | rights of fair use or other equivalent, as provided by copyright law. 181 | 182 | You may make, run and propagate covered works that you do not 183 | convey, without conditions so long as your license otherwise remains 184 | in force. You may convey covered works to others for the sole purpose 185 | of having them make modifications exclusively for you, or provide you 186 | with facilities for running those works, provided that you comply with 187 | the terms of this License in conveying all material for which you do 188 | not control copyright. Those thus making or running the covered works 189 | for you must do so exclusively on your behalf, under your direction 190 | and control, on terms that prohibit them from making any copies of 191 | your copyrighted material outside their relationship with you. 192 | 193 | Conveying under any other circumstances is permitted solely under 194 | the conditions stated below. Sublicensing is not allowed; section 10 195 | makes it unnecessary. 196 | 197 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 198 | 199 | No covered work shall be deemed part of an effective technological 200 | measure under any applicable law fulfilling obligations under article 201 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 202 | similar laws prohibiting or restricting circumvention of such 203 | measures. 204 | 205 | When you convey a covered work, you waive any legal power to forbid 206 | circumvention of technological measures to the extent such circumvention 207 | is effected by exercising rights under this License with respect to 208 | the covered work, and you disclaim any intention to limit operation or 209 | modification of the work as a means of enforcing, against the work's 210 | users, your or third parties' legal rights to forbid circumvention of 211 | technological measures. 212 | 213 | 4. Conveying Verbatim Copies. 214 | 215 | You may convey verbatim copies of the Program's source code as you 216 | receive it, in any medium, provided that you conspicuously and 217 | appropriately publish on each copy an appropriate copyright notice; 218 | keep intact all notices stating that this License and any 219 | non-permissive terms added in accord with section 7 apply to the code; 220 | keep intact all notices of the absence of any warranty; and give all 221 | recipients a copy of this License along with the Program. 222 | 223 | You may charge any price or no price for each copy that you convey, 224 | and you may offer support or warranty protection for a fee. 225 | 226 | 5. Conveying Modified Source Versions. 227 | 228 | You may convey a work based on the Program, or the modifications to 229 | produce it from the Program, in the form of source code under the 230 | terms of section 4, provided that you also meet all of these conditions: 231 | 232 | a) The work must carry prominent notices stating that you modified 233 | it, and giving a relevant date. 234 | 235 | b) The work must carry prominent notices stating that it is 236 | released under this License and any conditions added under section 237 | 7. This requirement modifies the requirement in section 4 to 238 | "keep intact all notices". 239 | 240 | c) You must license the entire work, as a whole, under this 241 | License to anyone who comes into possession of a copy. This 242 | License will therefore apply, along with any applicable section 7 243 | additional terms, to the whole of the work, and all its parts, 244 | regardless of how they are packaged. This License gives no 245 | permission to license the work in any other way, but it does not 246 | invalidate such permission if you have separately received it. 247 | 248 | d) If the work has interactive user interfaces, each must display 249 | Appropriate Legal Notices; however, if the Program has interactive 250 | interfaces that do not display Appropriate Legal Notices, your 251 | work need not make them do so. 252 | 253 | A compilation of a covered work with other separate and independent 254 | works, which are not by their nature extensions of the covered work, 255 | and which are not combined with it such as to form a larger program, 256 | in or on a volume of a storage or distribution medium, is called an 257 | "aggregate" if the compilation and its resulting copyright are not 258 | used to limit the access or legal rights of the compilation's users 259 | beyond what the individual works permit. Inclusion of a covered work 260 | in an aggregate does not cause this License to apply to the other 261 | parts of the aggregate. 262 | 263 | 6. Conveying Non-Source Forms. 264 | 265 | You may convey a covered work in object code form under the terms 266 | of sections 4 and 5, provided that you also convey the 267 | machine-readable Corresponding Source under the terms of this License, 268 | in one of these ways: 269 | 270 | a) Convey the object code in, or embodied in, a physical product 271 | (including a physical distribution medium), accompanied by the 272 | Corresponding Source fixed on a durable physical medium 273 | customarily used for software interchange. 274 | 275 | b) Convey the object code in, or embodied in, a physical product 276 | (including a physical distribution medium), accompanied by a 277 | written offer, valid for at least three years and valid for as 278 | long as you offer spare parts or customer support for that product 279 | model, to give anyone who possesses the object code either (1) a 280 | copy of the Corresponding Source for all the software in the 281 | product that is covered by this License, on a durable physical 282 | medium customarily used for software interchange, for a price no 283 | more than your reasonable cost of physically performing this 284 | conveying of source, or (2) access to copy the 285 | Corresponding Source from a network server at no charge. 286 | 287 | c) Convey individual copies of the object code with a copy of the 288 | written offer to provide the Corresponding Source. This 289 | alternative is allowed only occasionally and noncommercially, and 290 | only if you received the object code with such an offer, in accord 291 | with subsection 6b. 292 | 293 | d) Convey the object code by offering access from a designated 294 | place (gratis or for a charge), and offer equivalent access to the 295 | Corresponding Source in the same way through the same place at no 296 | further charge. You need not require recipients to copy the 297 | Corresponding Source along with the object code. If the place to 298 | copy the object code is a network server, the Corresponding Source 299 | may be on a different server (operated by you or a third party) 300 | that supports equivalent copying facilities, provided you maintain 301 | clear directions next to the object code saying where to find the 302 | Corresponding Source. Regardless of what server hosts the 303 | Corresponding Source, you remain obligated to ensure that it is 304 | available for as long as needed to satisfy these requirements. 305 | 306 | e) Convey the object code using peer-to-peer transmission, provided 307 | you inform other peers where the object code and Corresponding 308 | Source of the work are being offered to the general public at no 309 | charge under subsection 6d. 310 | 311 | A separable portion of the object code, whose source code is excluded 312 | from the Corresponding Source as a System Library, need not be 313 | included in conveying the object code work. 314 | 315 | A "User Product" is either (1) a "consumer product", which means any 316 | tangible personal property which is normally used for personal, family, 317 | or household purposes, or (2) anything designed or sold for incorporation 318 | into a dwelling. In determining whether a product is a consumer product, 319 | doubtful cases shall be resolved in favor of coverage. For a particular 320 | product received by a particular user, "normally used" refers to a 321 | typical or common use of that class of product, regardless of the status 322 | of the particular user or of the way in which the particular user 323 | actually uses, or expects or is expected to use, the product. A product 324 | is a consumer product regardless of whether the product has substantial 325 | commercial, industrial or non-consumer uses, unless such uses represent 326 | the only significant mode of use of the product. 327 | 328 | "Installation Information" for a User Product means any methods, 329 | procedures, authorization keys, or other information required to install 330 | and execute modified versions of a covered work in that User Product from 331 | a modified version of its Corresponding Source. The information must 332 | suffice to ensure that the continued functioning of the modified object 333 | code is in no case prevented or interfered with solely because 334 | modification has been made. 335 | 336 | If you convey an object code work under this section in, or with, or 337 | specifically for use in, a User Product, and the conveying occurs as 338 | part of a transaction in which the right of possession and use of the 339 | User Product is transferred to the recipient in perpetuity or for a 340 | fixed term (regardless of how the transaction is characterized), the 341 | Corresponding Source conveyed under this section must be accompanied 342 | by the Installation Information. But this requirement does not apply 343 | if neither you nor any third party retains the ability to install 344 | modified object code on the User Product (for example, the work has 345 | been installed in ROM). 346 | 347 | The requirement to provide Installation Information does not include a 348 | requirement to continue to provide support service, warranty, or updates 349 | for a work that has been modified or installed by the recipient, or for 350 | the User Product in which it has been modified or installed. Access to a 351 | network may be denied when the modification itself materially and 352 | adversely affects the operation of the network or violates the rules and 353 | protocols for communication across the network. 354 | 355 | Corresponding Source conveyed, and Installation Information provided, 356 | in accord with this section must be in a format that is publicly 357 | documented (and with an implementation available to the public in 358 | source code form), and must require no special password or key for 359 | unpacking, reading or copying. 360 | 361 | 7. Additional Terms. 362 | 363 | "Additional permissions" are terms that supplement the terms of this 364 | License by making exceptions from one or more of its conditions. 365 | Additional permissions that are applicable to the entire Program shall 366 | be treated as though they were included in this License, to the extent 367 | that they are valid under applicable law. If additional permissions 368 | apply only to part of the Program, that part may be used separately 369 | under those permissions, but the entire Program remains governed by 370 | this License without regard to the additional permissions. 371 | 372 | When you convey a copy of a covered work, you may at your option 373 | remove any additional permissions from that copy, or from any part of 374 | it. (Additional permissions may be written to require their own 375 | removal in certain cases when you modify the work.) You may place 376 | additional permissions on material, added by you to a covered work, 377 | for which you have or can give appropriate copyright permission. 378 | 379 | Notwithstanding any other provision of this License, for material you 380 | add to a covered work, you may (if authorized by the copyright holders of 381 | that material) supplement the terms of this License with terms: 382 | 383 | a) Disclaiming warranty or limiting liability differently from the 384 | terms of sections 15 and 16 of this License; or 385 | 386 | b) Requiring preservation of specified reasonable legal notices or 387 | author attributions in that material or in the Appropriate Legal 388 | Notices displayed by works containing it; or 389 | 390 | c) Prohibiting misrepresentation of the origin of that material, or 391 | requiring that modified versions of such material be marked in 392 | reasonable ways as different from the original version; or 393 | 394 | d) Limiting the use for publicity purposes of names of licensors or 395 | authors of the material; or 396 | 397 | e) Declining to grant rights under trademark law for use of some 398 | trade names, trademarks, or service marks; or 399 | 400 | f) Requiring indemnification of licensors and authors of that 401 | material by anyone who conveys the material (or modified versions of 402 | it) with contractual assumptions of liability to the recipient, for 403 | any liability that these contractual assumptions directly impose on 404 | those licensors and authors. 405 | 406 | All other non-permissive additional terms are considered "further 407 | restrictions" within the meaning of section 10. If the Program as you 408 | received it, or any part of it, contains a notice stating that it is 409 | governed by this License along with a term that is a further 410 | restriction, you may remove that term. If a license document contains 411 | a further restriction but permits relicensing or conveying under this 412 | License, you may add to a covered work material governed by the terms 413 | of that license document, provided that the further restriction does 414 | not survive such relicensing or conveying. 415 | 416 | If you add terms to a covered work in accord with this section, you 417 | must place, in the relevant source files, a statement of the 418 | additional terms that apply to those files, or a notice indicating 419 | where to find the applicable terms. 420 | 421 | Additional terms, permissive or non-permissive, may be stated in the 422 | form of a separately written license, or stated as exceptions; 423 | the above requirements apply either way. 424 | 425 | 8. Termination. 426 | 427 | You may not propagate or modify a covered work except as expressly 428 | provided under this License. Any attempt otherwise to propagate or 429 | modify it is void, and will automatically terminate your rights under 430 | this License (including any patent licenses granted under the third 431 | paragraph of section 11). 432 | 433 | However, if you cease all violation of this License, then your 434 | license from a particular copyright holder is reinstated (a) 435 | provisionally, unless and until the copyright holder explicitly and 436 | finally terminates your license, and (b) permanently, if the copyright 437 | holder fails to notify you of the violation by some reasonable means 438 | prior to 60 days after the cessation. 439 | 440 | Moreover, your license from a particular copyright holder is 441 | reinstated permanently if the copyright holder notifies you of the 442 | violation by some reasonable means, this is the first time you have 443 | received notice of violation of this License (for any work) from that 444 | copyright holder, and you cure the violation prior to 30 days after 445 | your receipt of the notice. 446 | 447 | Termination of your rights under this section does not terminate the 448 | licenses of parties who have received copies or rights from you under 449 | this License. If your rights have been terminated and not permanently 450 | reinstated, you do not qualify to receive new licenses for the same 451 | material under section 10. 452 | 453 | 9. Acceptance Not Required for Having Copies. 454 | 455 | You are not required to accept this License in order to receive or 456 | run a copy of the Program. Ancillary propagation of a covered work 457 | occurring solely as a consequence of using peer-to-peer transmission 458 | to receive a copy likewise does not require acceptance. However, 459 | nothing other than this License grants you permission to propagate or 460 | modify any covered work. These actions infringe copyright if you do 461 | not accept this License. Therefore, by modifying or propagating a 462 | covered work, you indicate your acceptance of this License to do so. 463 | 464 | 10. Automatic Licensing of Downstream Recipients. 465 | 466 | Each time you convey a covered work, the recipient automatically 467 | receives a license from the original licensors, to run, modify and 468 | propagate that work, subject to this License. You are not responsible 469 | for enforcing compliance by third parties with this License. 470 | 471 | An "entity transaction" is a transaction transferring control of an 472 | organization, or substantially all assets of one, or subdividing an 473 | organization, or merging organizations. If propagation of a covered 474 | work results from an entity transaction, each party to that 475 | transaction who receives a copy of the work also receives whatever 476 | licenses to the work the party's predecessor in interest had or could 477 | give under the previous paragraph, plus a right to possession of the 478 | Corresponding Source of the work from the predecessor in interest, if 479 | the predecessor has it or can get it with reasonable efforts. 480 | 481 | You may not impose any further restrictions on the exercise of the 482 | rights granted or affirmed under this License. For example, you may 483 | not impose a license fee, royalty, or other charge for exercise of 484 | rights granted under this License, and you may not initiate litigation 485 | (including a cross-claim or counterclaim in a lawsuit) alleging that 486 | any patent claim is infringed by making, using, selling, offering for 487 | sale, or importing the Program or any portion of it. 488 | 489 | 11. Patents. 490 | 491 | A "contributor" is a copyright holder who authorizes use under this 492 | License of the Program or a work on which the Program is based. The 493 | work thus licensed is called the contributor's "contributor version". 494 | 495 | A contributor's "essential patent claims" are all patent claims 496 | owned or controlled by the contributor, whether already acquired or 497 | hereafter acquired, that would be infringed by some manner, permitted 498 | by this License, of making, using, or selling its contributor version, 499 | but do not include claims that would be infringed only as a 500 | consequence of further modification of the contributor version. For 501 | purposes of this definition, "control" includes the right to grant 502 | patent sublicenses in a manner consistent with the requirements of 503 | this License. 504 | 505 | Each contributor grants you a non-exclusive, worldwide, royalty-free 506 | patent license under the contributor's essential patent claims, to 507 | make, use, sell, offer for sale, import and otherwise run, modify and 508 | propagate the contents of its contributor version. 509 | 510 | In the following three paragraphs, a "patent license" is any express 511 | agreement or commitment, however denominated, not to enforce a patent 512 | (such as an express permission to practice a patent or covenant not to 513 | sue for patent infringement). To "grant" such a patent license to a 514 | party means to make such an agreement or commitment not to enforce a 515 | patent against the party. 516 | 517 | If you convey a covered work, knowingly relying on a patent license, 518 | and the Corresponding Source of the work is not available for anyone 519 | to copy, free of charge and under the terms of this License, through a 520 | publicly available network server or other readily accessible means, 521 | then you must either (1) cause the Corresponding Source to be so 522 | available, or (2) arrange to deprive yourself of the benefit of the 523 | patent license for this particular work, or (3) arrange, in a manner 524 | consistent with the requirements of this License, to extend the patent 525 | license to downstream recipients. "Knowingly relying" means you have 526 | actual knowledge that, but for the patent license, your conveying the 527 | covered work in a country, or your recipient's use of the covered work 528 | in a country, would infringe one or more identifiable patents in that 529 | country that you have reason to believe are valid. 530 | 531 | If, pursuant to or in connection with a single transaction or 532 | arrangement, you convey, or propagate by procuring conveyance of, a 533 | covered work, and grant a patent license to some of the parties 534 | receiving the covered work authorizing them to use, propagate, modify 535 | or convey a specific copy of the covered work, then the patent license 536 | you grant is automatically extended to all recipients of the covered 537 | work and works based on it. 538 | 539 | A patent license is "discriminatory" if it does not include within 540 | the scope of its coverage, prohibits the exercise of, or is 541 | conditioned on the non-exercise of one or more of the rights that are 542 | specifically granted under this License. You may not convey a covered 543 | work if you are a party to an arrangement with a third party that is 544 | in the business of distributing software, under which you make payment 545 | to the third party based on the extent of your activity of conveying 546 | the work, and under which the third party grants, to any of the 547 | parties who would receive the covered work from you, a discriminatory 548 | patent license (a) in connection with copies of the covered work 549 | conveyed by you (or copies made from those copies), or (b) primarily 550 | for and in connection with specific products or compilations that 551 | contain the covered work, unless you entered into that arrangement, 552 | or that patent license was granted, prior to 28 March 2007. 553 | 554 | Nothing in this License shall be construed as excluding or limiting 555 | any implied license or other defenses to infringement that may 556 | otherwise be available to you under applicable patent law. 557 | 558 | 12. No Surrender of Others' Freedom. 559 | 560 | If conditions are imposed on you (whether by court order, agreement or 561 | otherwise) that contradict the conditions of this License, they do not 562 | excuse you from the conditions of this License. If you cannot convey a 563 | covered work so as to satisfy simultaneously your obligations under this 564 | License and any other pertinent obligations, then as a consequence you may 565 | not convey it at all. For example, if you agree to terms that obligate you 566 | to collect a royalty for further conveying from those to whom you convey 567 | the Program, the only way you could satisfy both those terms and this 568 | License would be to refrain entirely from conveying the Program. 569 | 570 | 13. Use with the GNU Affero General Public License. 571 | 572 | Notwithstanding any other provision of this License, you have 573 | permission to link or combine any covered work with a work licensed 574 | under version 3 of the GNU Affero General Public License into a single 575 | combined work, and to convey the resulting work. The terms of this 576 | License will continue to apply to the part which is the covered work, 577 | but the special requirements of the GNU Affero General Public License, 578 | section 13, concerning interaction through a network will apply to the 579 | combination as such. 580 | 581 | 14. Revised Versions of this License. 582 | 583 | The Free Software Foundation may publish revised and/or new versions of 584 | the GNU General Public License from time to time. Such new versions will 585 | be similar in spirit to the present version, but may differ in detail to 586 | address new problems or concerns. 587 | 588 | Each version is given a distinguishing version number. If the 589 | Program specifies that a certain numbered version of the GNU General 590 | Public License "or any later version" applies to it, you have the 591 | option of following the terms and conditions either of that numbered 592 | version or of any later version published by the Free Software 593 | Foundation. If the Program does not specify a version number of the 594 | GNU General Public License, you may choose any version ever published 595 | by the Free Software Foundation. 596 | 597 | If the Program specifies that a proxy can decide which future 598 | versions of the GNU General Public License can be used, that proxy's 599 | public statement of acceptance of a version permanently authorizes you 600 | to choose that version for the Program. 601 | 602 | Later license versions may give you additional or different 603 | permissions. However, no additional obligations are imposed on any 604 | author or copyright holder as a result of your choosing to follow a 605 | later version. 606 | 607 | 15. Disclaimer of Warranty. 608 | 609 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 610 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 611 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 612 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 613 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 614 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 615 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 616 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 617 | 618 | 16. Limitation of Liability. 619 | 620 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 621 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 622 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 623 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 624 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 625 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 626 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 627 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 628 | SUCH DAMAGES. 629 | 630 | 17. Interpretation of Sections 15 and 16. 631 | 632 | If the disclaimer of warranty and limitation of liability provided 633 | above cannot be given local legal effect according to their terms, 634 | reviewing courts shall apply local law that most closely approximates 635 | an absolute waiver of all civil liability in connection with the 636 | Program, unless a warranty or assumption of liability accompanies a 637 | copy of the Program in return for a fee. 638 | 639 | END OF TERMS AND CONDITIONS 640 | 641 | How to Apply These Terms to Your New Programs 642 | 643 | If you develop a new program, and you want it to be of the greatest 644 | possible use to the public, the best way to achieve this is to make it 645 | free software which everyone can redistribute and change under these terms. 646 | 647 | To do so, attach the following notices to the program. It is safest 648 | to attach them to the start of each source file to most effectively 649 | state the exclusion of warranty; and each file should have at least 650 | the "copyright" line and a pointer to where the full notice is found. 651 | 652 | {one line to give the program's name and a brief idea of what it does.} 653 | Copyright (C) {year} {name of author} 654 | 655 | This program is free software: you can redistribute it and/or modify 656 | it under the terms of the GNU General Public License as published by 657 | the Free Software Foundation, either version 3 of the License, or 658 | (at your option) any later version. 659 | 660 | This program is distributed in the hope that it will be useful, 661 | but WITHOUT ANY WARRANTY; without even the implied warranty of 662 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 663 | GNU General Public License for more details. 664 | 665 | You should have received a copy of the GNU General Public License 666 | along with this program. If not, see . 667 | 668 | Also add information on how to contact you by electronic and paper mail. 669 | 670 | If the program does terminal interaction, make it output a short 671 | notice like this when it starts in an interactive mode: 672 | 673 | {project} Copyright (C) {year} {fullname} 674 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 675 | This is free software, and you are welcome to redistribute it 676 | under certain conditions; type `show c' for details. 677 | 678 | The hypothetical commands `show w' and `show c' should show the appropriate 679 | parts of the General Public License. Of course, your program's commands 680 | might be different; for a GUI interface, you would use an "about box". 681 | 682 | You should also get your employer (if you work as a programmer) or school, 683 | if any, to sign a "copyright disclaimer" for the program, if necessary. 684 | For more information on this, and how to apply and follow the GNU GPL, see 685 | . 686 | 687 | The GNU General Public License does not permit incorporating your program 688 | into proprietary programs. If your program is a subroutine library, you 689 | may consider it more useful to permit linking proprietary applications with 690 | the library. If this is what you want to do, use the GNU Lesser General 691 | Public License instead of this License. But first, please read 692 | . -------------------------------------------------------------------------------- /OsuHelper.Tests/Logic/BeatmapTraitsLogicTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using FluentAssertions; 4 | using NUnit.Framework; 5 | using OsuHelper.Logic; 6 | using OsuHelper.Models; 7 | 8 | namespace OsuHelper.Tests.Logic 9 | { 10 | [TestFixture] 11 | public class BeatmapTraitsLogicTests 12 | { 13 | private static IEnumerable GetTestCases_CalculateTraitsWithMods() 14 | { 15 | // Nomod 16 | yield return new TestCaseData( 17 | // Input 18 | new BeatmapTraits( 19 | 100, 20 | new TimeSpan(00, 01, 30), 21 | 200, 5, 9, 8, 8, 7 22 | ), 23 | Mods.None, 24 | GameMode.Standard, 25 | 26 | // Output 27 | new BeatmapTraits( 28 | 100, 29 | new TimeSpan(00, 01, 30), 30 | 200, 5, 9, 8, 8, 7 31 | ) 32 | ); 33 | 34 | // Hardrock 35 | yield return new TestCaseData( 36 | // Input 37 | new BeatmapTraits( 38 | 100, 39 | new TimeSpan(00, 01, 30), 40 | 200, 5, 9, 8, 8, 7 41 | ), 42 | Mods.HardRock, 43 | GameMode.Standard, 44 | 45 | // Output 46 | new BeatmapTraits( 47 | 100, 48 | new TimeSpan(00, 01, 30), 49 | 200, 5, 10, 10, 10, 9.8 50 | ) 51 | ); 52 | 53 | // Easy 54 | yield return new TestCaseData( 55 | // Input 56 | new BeatmapTraits( 57 | 100, 58 | new TimeSpan(00, 01, 30), 59 | 200, 5, 9, 8, 8, 7 60 | ), 61 | Mods.Easy, 62 | GameMode.Standard, 63 | 64 | // Output 65 | new BeatmapTraits( 66 | 100, 67 | new TimeSpan(00, 01, 30), 68 | 200, 5, 4.5, 4, 4, 3.5 69 | ) 70 | ); 71 | 72 | // DoubleTime 73 | yield return new TestCaseData( 74 | // Input 75 | new BeatmapTraits( 76 | 100, 77 | new TimeSpan(00, 01, 30), 78 | 200, 5, 9, 8, 8, 7 79 | ), 80 | Mods.DoubleTime, 81 | GameMode.Standard, 82 | 83 | // Output 84 | new BeatmapTraits( 85 | 100, 86 | new TimeSpan(00, 01, 00), 87 | 300, 5, 10.33, 9.67, 8, 7 88 | ) 89 | ); 90 | 91 | // HalfTime 92 | yield return new TestCaseData( 93 | // Input 94 | new BeatmapTraits( 95 | 100, 96 | new TimeSpan(00, 01, 30), 97 | 200, 5, 9, 8, 8, 7 98 | ), 99 | Mods.HalfTime, 100 | GameMode.Standard, 101 | 102 | // Output 103 | new BeatmapTraits( 104 | 100, 105 | new TimeSpan(00, 02, 00), 106 | 150, 5, 7.67, 6.33, 8, 7 107 | ) 108 | ); 109 | 110 | // DoubleTime + HardRock 111 | yield return new TestCaseData( 112 | // Input 113 | new BeatmapTraits( 114 | 100, 115 | new TimeSpan(00, 01, 30), 116 | 200, 5, 9, 8, 8, 7 117 | ), 118 | Mods.DoubleTime | Mods.HardRock, 119 | GameMode.Standard, 120 | 121 | // Output 122 | new BeatmapTraits( 123 | 100, 124 | new TimeSpan(00, 01, 00), 125 | 300, 5, 11, 11, 10, 9.8 126 | ) 127 | ); 128 | 129 | // DoubleTime + Easy 130 | yield return new TestCaseData( 131 | // Input 132 | new BeatmapTraits( 133 | 100, 134 | new TimeSpan(00, 01, 30), 135 | 200, 5, 9, 8, 8, 7 136 | ), 137 | Mods.DoubleTime | Mods.Easy, 138 | GameMode.Standard, 139 | 140 | // Output 141 | new BeatmapTraits( 142 | 100, 143 | new TimeSpan(00, 01, 00), 144 | 300, 5, 7.4, 7, 4, 3.5 145 | ) 146 | ); 147 | 148 | // HalfTime + HardRock 149 | yield return new TestCaseData( 150 | // Input 151 | new BeatmapTraits( 152 | 100, 153 | new TimeSpan(00, 01, 30), 154 | 200, 5, 9, 8, 8, 7 155 | ), 156 | Mods.HalfTime | Mods.HardRock, 157 | GameMode.Standard, 158 | 159 | // Output 160 | new BeatmapTraits( 161 | 100, 162 | new TimeSpan(00, 02, 00), 163 | 150, 5, 9, 9, 10, 9.8 164 | ) 165 | ); 166 | 167 | // HalfTime + Easy 168 | yield return new TestCaseData( 169 | // Input 170 | new BeatmapTraits( 171 | 100, 172 | new TimeSpan(00, 01, 30), 173 | 200, 5, 9, 8, 8, 7 174 | ), 175 | Mods.HalfTime | Mods.Easy, 176 | GameMode.Standard, 177 | 178 | // Output 179 | new BeatmapTraits( 180 | 100, 181 | new TimeSpan(00, 02, 00), 182 | 150, 5, 1, 1, 4, 3.5 183 | ) 184 | ); 185 | } 186 | 187 | [Test] 188 | [TestCaseSource(nameof(GetTestCases_CalculateTraitsWithMods))] 189 | public void CalculateTraitsWithMods( 190 | BeatmapTraits nomodTraits, 191 | Mods mods, 192 | GameMode mode, 193 | BeatmapTraits expectedTraits) 194 | { 195 | // Act 196 | var traits = BeatmapTraitsLogic.CalculateTraitsWithMods(nomodTraits, mods, mode); 197 | 198 | // Assert 199 | traits.Should().BeEquivalentTo(expectedTraits, 200 | o => o.Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, 0.01)).WhenTypeIs()); 201 | } 202 | } 203 | } -------------------------------------------------------------------------------- /OsuHelper.Tests/OsuHelper.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /OsuHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29509.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OsuHelper", "OsuHelper\OsuHelper.csproj", "{8AC46029-3A41-4875-88FD-6C66C4B452DB}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B672C5B8-00D1-4B9D-B998-2D05976CA76C}" 9 | ProjectSection(SolutionItems) = preProject 10 | Changelog.md = Changelog.md 11 | License.txt = License.txt 12 | ReadMe.md = ReadMe.md 13 | Directory.Build.props = Directory.Build.props 14 | EndProjectSection 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OsuHelper.Tests", "OsuHelper.Tests\OsuHelper.Tests.csproj", "{54232843-DA2F-4EEE-979B-94A20F410312}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {8AC46029-3A41-4875-88FD-6C66C4B452DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {8AC46029-3A41-4875-88FD-6C66C4B452DB}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {8AC46029-3A41-4875-88FD-6C66C4B452DB}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {8AC46029-3A41-4875-88FD-6C66C4B452DB}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {54232843-DA2F-4EEE-979B-94A20F410312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {54232843-DA2F-4EEE-979B-94A20F410312}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {54232843-DA2F-4EEE-979B-94A20F410312}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {54232843-DA2F-4EEE-979B-94A20F410312}.Release|Any CPU.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(ExtensibilityGlobals) = postSolution 37 | SolutionGuid = {3898A9CF-41F7-4277-8033-B529D43BC11B} 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /OsuHelper.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | AR 3 | BPM 4 | CS 5 | OD 6 | PP -------------------------------------------------------------------------------- /OsuHelper/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | #343838 22 | #5E6262 23 | #0D1212 24 | #F9A825 25 | #C17900 26 | #000000 27 | #FFFFFF 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 49 | 50 | 59 | 60 | 77 | 78 | 89 | 90 | 93 | 94 | 99 | 100 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /OsuHelper/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace OsuHelper 5 | { 6 | public partial class App 7 | { 8 | private static readonly Assembly Assembly = typeof(App).Assembly; 9 | 10 | public static string Name => Assembly.GetName().Name!; 11 | 12 | public static Version Version => Assembly.GetName().Version!; 13 | 14 | public static string VersionString => Version.ToString(3); 15 | 16 | public static string GitHubProjectUrl { get; } = "https://github.com/Tyrrrz/OsuHelper"; 17 | 18 | public static string ExecutableDirPath => AppDomain.CurrentDomain.BaseDirectory!; 19 | } 20 | } -------------------------------------------------------------------------------- /OsuHelper/Bootstrapper.cs: -------------------------------------------------------------------------------- 1 | using OsuHelper.Services; 2 | using OsuHelper.ViewModels; 3 | using OsuHelper.ViewModels.Framework; 4 | using Stylet; 5 | using StyletIoC; 6 | 7 | #if !DEBUG 8 | using System.Windows; 9 | using System.Windows.Threading; 10 | #endif 11 | 12 | namespace OsuHelper 13 | { 14 | public class Bootstrapper : Bootstrapper 15 | { 16 | protected override void ConfigureIoC(IStyletIoCBuilder builder) 17 | { 18 | base.ConfigureIoC(builder); 19 | 20 | // Bind settings as singleton 21 | builder.Bind().ToSelf().InSingletonScope(); 22 | 23 | // Bind view model factory 24 | builder.Bind().ToAbstractFactory(); 25 | } 26 | 27 | #if !DEBUG 28 | protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) 29 | { 30 | base.OnUnhandledException(e); 31 | 32 | MessageBox.Show(e.Exception.ToString(), "Error occured", MessageBoxButton.OK, MessageBoxImage.Error); 33 | } 34 | #endif 35 | } 36 | } -------------------------------------------------------------------------------- /OsuHelper/Converters/ModsToStringConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using OsuHelper.Models; 5 | 6 | namespace OsuHelper.Converters 7 | { 8 | [ValueConversion(typeof(Mods), typeof(string))] 9 | public class ModsToStringConverter : IValueConverter 10 | { 11 | public static ModsToStringConverter Instance { get; } = new(); 12 | 13 | public object? Convert(object? value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | var mods = (Mods?) value; 16 | return mods?.FormatToString(); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => 20 | throw new NotImplementedException(); 21 | } 22 | } -------------------------------------------------------------------------------- /OsuHelper/Converters/TimeSpanToShortStringConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace OsuHelper.Converters 6 | { 7 | [ValueConversion(typeof(TimeSpan), typeof(string))] 8 | public class TimeSpanToShortStringConverter : IValueConverter 9 | { 10 | public static TimeSpanToShortStringConverter Instance { get; } = new(); 11 | 12 | public object? Convert(object? value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (value is null) 15 | return null; 16 | 17 | var time = (TimeSpan) value; 18 | var fullMins = time.Hours * 60 + time.Minutes; 19 | 20 | return $"{fullMins:00}:{time.Seconds:00}"; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => 24 | throw new NotImplementedException(); 25 | } 26 | } -------------------------------------------------------------------------------- /OsuHelper/Exceptions/HttpErrorStatusCodeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace OsuHelper.Exceptions 5 | { 6 | public class HttpErrorStatusCodeException : Exception 7 | { 8 | public HttpStatusCode StatusCode { get; } 9 | 10 | public HttpErrorStatusCodeException(HttpStatusCode statusCode) 11 | : base($"Response status code does not indicate success: {(int) statusCode} ({statusCode}).") 12 | { 13 | StatusCode = statusCode; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /OsuHelper/Exceptions/RecommendationsUnavailableException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Exceptions 4 | { 5 | public class RecommendationsUnavailableException : Exception 6 | { 7 | public RecommendationsUnavailableException(string message) 8 | : base(message) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /OsuHelper/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /OsuHelper/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Used to control if the On_PropertyName_Changed feature is enabled. 12 | 13 | 14 | 15 | 16 | Used to control if the Dependent properties feature is enabled. 17 | 18 | 19 | 20 | 21 | Used to control if the IsChanged property feature is enabled. 22 | 23 | 24 | 25 | 26 | Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. 27 | 28 | 29 | 30 | 31 | Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project. 32 | 33 | 34 | 35 | 36 | Used to control if equality checks should use the Equals method resolved from the base class. 37 | 38 | 39 | 40 | 41 | Used to control if equality checks should use the static Equals method resolved from the base class. 42 | 43 | 44 | 45 | 46 | Used to turn off build warnings from this weaver. 47 | 48 | 49 | 50 | 51 | Used to turn off build warnings about mismatched On_PropertyName_Changed methods. 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 60 | 61 | 62 | 63 | 64 | A comma-separated list of error codes that can be safely ignored in assembly verification. 65 | 66 | 67 | 68 | 69 | 'false' to turn off automatic generation of the XML Schema file. 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /OsuHelper/Internal/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Internal 4 | { 5 | internal static class Extensions 6 | { 7 | public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime) => new(dateTime); 8 | } 9 | } -------------------------------------------------------------------------------- /OsuHelper/Internal/ProcessEx.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace OsuHelper.Internal 4 | { 5 | internal static class ProcessEx 6 | { 7 | public static void StartShellExecute(string path) 8 | { 9 | var startInfo = new ProcessStartInfo(path) 10 | { 11 | UseShellExecute = true 12 | }; 13 | 14 | using (Process.Start(startInfo)) 15 | { } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /OsuHelper/Logic/BeatmapTraitsLogic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OsuHelper.Models; 3 | 4 | namespace OsuHelper.Logic 5 | { 6 | public static class BeatmapTraitsLogic 7 | { 8 | private static TimeSpan ApproachRateToTime(double ar) 9 | { 10 | return ar <= 5 11 | ? TimeSpan.FromMilliseconds(1800 - ar * 120) 12 | : TimeSpan.FromMilliseconds(1050 - (ar - 6) * 150); 13 | } 14 | 15 | private static double TimeToApproachRate(TimeSpan time) 16 | { 17 | var ms = time.TotalMilliseconds; 18 | return ms > 1200 19 | ? (1800 - ms) / 120 20 | : (1050 - ms) / 150 + 6; 21 | } 22 | 23 | private static TimeSpan OverallDifficultyToTime(double od) 24 | { 25 | return TimeSpan.FromMilliseconds(78 - od * 6); 26 | } 27 | 28 | private static double TimeToOverallDifficulty(TimeSpan time) 29 | { 30 | var ms = time.TotalMilliseconds; 31 | return (78 - ms) / 6; 32 | } 33 | 34 | private static TimeSpan DoubleTimeDuration(TimeSpan originalDuration) => originalDuration / 1.5; 35 | 36 | private static TimeSpan HalfTimeDuration(TimeSpan originalDuration) => originalDuration / 0.75; 37 | 38 | private static double DoubleTimeTempo(double originalTempo) => originalTempo * 1.5; 39 | 40 | private static double HalfTimeTempo(double originalTempo) => originalTempo * 0.75; 41 | 42 | private static double HardRockApproachRate(double originalApproachRate) => Math.Min(10, originalApproachRate * 1.4); 43 | 44 | private static double HardRockOverallDifficulty(double originalOverallDifficulty) => Math.Min(10, originalOverallDifficulty * 1.4); 45 | 46 | private static double HardRockCircleSize(double originalCircleSize) => Math.Min(10, originalCircleSize * 1.4); 47 | 48 | private static double HardRockDrain(double originalDrain) => Math.Min(10, originalDrain * 1.4); 49 | 50 | private static double EasyApproachRate(double originalApproachRate) => originalApproachRate / 2; 51 | 52 | private static double EasyOverallDifficulty(double originalOverallDifficulty) => originalOverallDifficulty / 2; 53 | 54 | private static double EasyCircleSize(double originalCircleSize) => originalCircleSize / 2; 55 | 56 | private static double EasyDrain(double originalDrain) => originalDrain / 2; 57 | 58 | private static double DoubleTimeApproachRate(double originalApproachRate) => 59 | originalApproachRate 60 | .Pipe(ApproachRateToTime) 61 | .Pipe(DoubleTimeDuration) 62 | .Pipe(TimeToApproachRate); 63 | 64 | private static double HalfTimeApproachRate(double originalApproachRate) => 65 | originalApproachRate 66 | .Pipe(ApproachRateToTime) 67 | .Pipe(HalfTimeDuration) 68 | .Pipe(TimeToApproachRate); 69 | 70 | private static double DoubleTimeOverallDifficulty(double originalApproachRate) => 71 | originalApproachRate 72 | .Pipe(OverallDifficultyToTime) 73 | .Pipe(DoubleTimeDuration) 74 | .Pipe(TimeToOverallDifficulty); 75 | 76 | private static double HalfTimeOverallDifficulty(double originalApproachRate) => 77 | originalApproachRate 78 | .Pipe(OverallDifficultyToTime) 79 | .Pipe(HalfTimeDuration) 80 | .Pipe(TimeToOverallDifficulty); 81 | 82 | private static TimeSpan AdjustDuration(TimeSpan originalDuration, Mods mods) 83 | { 84 | if (mods.HasFlag(Mods.DoubleTime)) 85 | return DoubleTimeDuration(originalDuration); 86 | 87 | if (mods.HasFlag(Mods.HalfTime)) 88 | return HalfTimeDuration(originalDuration); 89 | 90 | return originalDuration; 91 | } 92 | 93 | private static double AdjustTempo(double originalTempo, Mods mods) 94 | { 95 | if (mods.HasFlag(Mods.DoubleTime)) 96 | return DoubleTimeTempo(originalTempo); 97 | 98 | if (mods.HasFlag(Mods.HalfTime)) 99 | return HalfTimeTempo(originalTempo); 100 | 101 | return originalTempo; 102 | } 103 | 104 | private static double AdjustApproachRate(double originalApproachRate, Mods mods) 105 | { 106 | var approachRate = originalApproachRate; 107 | 108 | if (mods.HasFlag(Mods.HardRock)) 109 | approachRate = HardRockApproachRate(approachRate); 110 | else if (mods.HasFlag(Mods.Easy)) 111 | approachRate = EasyApproachRate(approachRate); 112 | 113 | if (mods.HasFlag(Mods.DoubleTime)) 114 | approachRate = DoubleTimeApproachRate(approachRate); 115 | else if (mods.HasFlag(Mods.HalfTime)) 116 | approachRate = HalfTimeApproachRate(approachRate); 117 | 118 | return approachRate; 119 | } 120 | 121 | private static double AdjustOverallDifficulty(double originalOverallDifficulty, Mods mods) 122 | { 123 | var overallDifficulty = originalOverallDifficulty; 124 | 125 | if (mods.HasFlag(Mods.HardRock)) 126 | overallDifficulty = HardRockOverallDifficulty(overallDifficulty); 127 | else if (mods.HasFlag(Mods.Easy)) 128 | overallDifficulty = EasyOverallDifficulty(overallDifficulty); 129 | 130 | if (mods.HasFlag(Mods.DoubleTime)) 131 | overallDifficulty = DoubleTimeOverallDifficulty(overallDifficulty); 132 | else if (mods.HasFlag(Mods.HalfTime)) 133 | overallDifficulty = HalfTimeOverallDifficulty(overallDifficulty); 134 | 135 | return overallDifficulty; 136 | } 137 | 138 | private static double AdjustCircleSize(double originalCircleSize, Mods mods) 139 | { 140 | if (mods.HasFlag(Mods.HardRock)) 141 | return HardRockCircleSize(originalCircleSize); 142 | 143 | if (mods.HasFlag(Mods.Easy)) 144 | return EasyCircleSize(originalCircleSize); 145 | 146 | return originalCircleSize; 147 | } 148 | 149 | private static double AdjustDrain(double originalDrain, Mods mods) 150 | { 151 | if (mods.HasFlag(Mods.HardRock)) 152 | return HardRockDrain(originalDrain); 153 | 154 | if (mods.HasFlag(Mods.Easy)) 155 | return EasyDrain(originalDrain); 156 | 157 | return originalDrain; 158 | } 159 | 160 | public static BeatmapTraits CalculateTraitsWithMods(BeatmapTraits nomodTraits, Mods mods, GameMode mode) 161 | { 162 | // No mods - just return base traits 163 | if (mods == Mods.None) 164 | return nomodTraits; 165 | 166 | // Not standard - return base traits (no idea how those mods work) 167 | if (mode != GameMode.Standard) 168 | return nomodTraits; 169 | 170 | return new BeatmapTraits( 171 | nomodTraits.MaxCombo, // doesn't change 172 | AdjustDuration(nomodTraits.Duration, mods), 173 | AdjustTempo(nomodTraits.Tempo, mods), 174 | nomodTraits.StarRating, // can't calculate 175 | AdjustApproachRate(nomodTraits.ApproachRate, mods), 176 | AdjustOverallDifficulty(nomodTraits.OverallDifficulty, mods), 177 | AdjustCircleSize(nomodTraits.CircleSize, mods), 178 | AdjustDrain(nomodTraits.Drain, mods) 179 | ); 180 | } 181 | } 182 | } -------------------------------------------------------------------------------- /OsuHelper/Logic/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Logic 4 | { 5 | internal static class Extensions 6 | { 7 | public static TOut Pipe(this TIn value, Func transform) => transform(value); 8 | } 9 | } -------------------------------------------------------------------------------- /OsuHelper/Models/Beatmap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Models 4 | { 5 | public class Beatmap 6 | { 7 | public string Id { get; } 8 | 9 | public string MapSetId { get; } 10 | 11 | public GameMode GameMode { get; } 12 | 13 | public string Creator { get; } 14 | 15 | public DateTimeOffset LastUpdate { get; } 16 | 17 | public string Artist { get; } 18 | 19 | public string Title { get; } 20 | 21 | public string Version { get; } 22 | 23 | public string FullName => $"{Artist} — {Title} [{Version}]"; 24 | 25 | public string MapSetFullName => $"{Artist} — {Title}"; 26 | 27 | public BeatmapTraits Traits { get; } 28 | 29 | public string ThumbnailUrl => $"https://b.ppy.sh/thumb/{MapSetId}l.jpg"; 30 | 31 | public string CoverUrl => $"https://assets.ppy.sh/beatmaps/{MapSetId}/covers/cover.jpg"; 32 | 33 | public string CardUrl => $"https://assets.ppy.sh/beatmaps/{MapSetId}/covers/card.jpg"; 34 | 35 | public Beatmap(string id, string mapSetId, GameMode gameMode, string creator, DateTimeOffset lastUpdate, 36 | string artist, string title, string version, BeatmapTraits traits) 37 | { 38 | Id = id; 39 | MapSetId = mapSetId; 40 | GameMode = gameMode; 41 | Creator = creator; 42 | LastUpdate = lastUpdate; 43 | Artist = artist; 44 | Title = title; 45 | Version = version; 46 | Traits = traits; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /OsuHelper/Models/BeatmapRankingStatus.cs: -------------------------------------------------------------------------------- 1 | namespace OsuHelper.Models 2 | { 3 | public enum BeatmapRankingStatus 4 | { 5 | Graveyard = -2, 6 | WorkInProgress = -1, 7 | Pending = 0, 8 | Ranked = 1, 9 | Approved = 2, 10 | Qualified = 3 11 | } 12 | } -------------------------------------------------------------------------------- /OsuHelper/Models/BeatmapTraits.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Models 4 | { 5 | public class BeatmapTraits 6 | { 7 | public int MaxCombo { get; } 8 | 9 | public TimeSpan Duration { get; } 10 | 11 | public double Tempo { get; } 12 | 13 | public double StarRating { get; } 14 | 15 | public double ApproachRate { get; } 16 | 17 | public double OverallDifficulty { get; } 18 | 19 | public double CircleSize { get; } 20 | 21 | public double Drain { get; } 22 | 23 | public BeatmapTraits(int maxCombo, TimeSpan duration, double tempo, double starRating, 24 | double approachRate, double overallDifficulty, double circleSize, double drain) 25 | { 26 | MaxCombo = maxCombo; 27 | Duration = duration; 28 | Tempo = tempo; 29 | StarRating = starRating; 30 | ApproachRate = approachRate; 31 | OverallDifficulty = overallDifficulty; 32 | CircleSize = circleSize; 33 | Drain = drain; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /OsuHelper/Models/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace OsuHelper.Models 4 | { 5 | public static class Extensions 6 | { 7 | public static string FormatToString(this Mods mods) 8 | { 9 | if (mods == Mods.None) return string.Empty; 10 | 11 | var buffer = new StringBuilder(); 12 | 13 | // Only mods that influence PP and/or are ranked 14 | if (mods.HasFlag(Mods.NoFail)) 15 | buffer.Append("NF"); 16 | if (mods.HasFlag(Mods.Easy)) 17 | buffer.Append("EZ"); 18 | if (mods.HasFlag(Mods.Hidden)) 19 | buffer.Append("HD"); 20 | if (mods.HasFlag(Mods.HardRock)) 21 | buffer.Append("HR"); 22 | if (mods.HasFlag(Mods.DoubleTime) || mods.HasFlag(Mods.Nightcore)) 23 | buffer.Append("DT"); 24 | if (mods.HasFlag(Mods.HalfTime)) 25 | buffer.Append("HT"); 26 | if (mods.HasFlag(Mods.Flashlight)) 27 | buffer.Append("FL"); 28 | if (mods.HasFlag(Mods.SpunOut)) 29 | buffer.Append("SO"); 30 | 31 | return buffer.ToString(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /OsuHelper/Models/GameMode.cs: -------------------------------------------------------------------------------- 1 | namespace OsuHelper.Models 2 | { 3 | public enum GameMode 4 | { 5 | Standard = 0, 6 | Taiko = 1, 7 | CatchTheBeat = 2, 8 | Mania = 3 9 | } 10 | } -------------------------------------------------------------------------------- /OsuHelper/Models/Mods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Models 4 | { 5 | [Flags] 6 | public enum Mods 7 | { 8 | None = 0, 9 | NoFail = 1, 10 | Easy = 2, 11 | NoVideo = 4, // Not used anymore, but can be found on old plays like Mesita on b/78239 12 | Hidden = 8, 13 | HardRock = 16, 14 | SuddenDeath = 32, 15 | DoubleTime = 64, 16 | Relax = 128, 17 | HalfTime = 256, 18 | Nightcore = 512, // Only set along with DoubleTime. i.e: NC only gives 576 19 | Flashlight = 1024, 20 | Autoplay = 2048, 21 | SpunOut = 4096, 22 | Relax2 = 8192, // Autopilot? 23 | Perfect = 16384, // Only set along with SuddenDeath. i.e: PF only gives 16416 24 | Key4 = 32768, 25 | Key5 = 65536, 26 | Key6 = 131072, 27 | Key7 = 262144, 28 | Key8 = 524288, 29 | KeyMod = Key4 | Key5 | Key6 | Key7 | Key8, 30 | FadeIn = 1048576, 31 | Random = 2097152, 32 | LastMod = 4194304, 33 | FreeModAllowed = NoFail | Easy | Hidden | HardRock | SuddenDeath | Flashlight | FadeIn | Relax | Relax2 | SpunOut | KeyMod, 34 | Key9 = 16777216, 35 | Key10 = 33554432, 36 | Key1 = 67108864, 37 | Key3 = 134217728, 38 | Key2 = 268435456 39 | } 40 | } -------------------------------------------------------------------------------- /OsuHelper/Models/Play.cs: -------------------------------------------------------------------------------- 1 | namespace OsuHelper.Models 2 | { 3 | public class Play 4 | { 5 | public string PlayerId { get; } 6 | 7 | public string BeatmapId { get; } 8 | 9 | public Mods Mods { get; } 10 | 11 | public PlayRank Rank { get; } 12 | 13 | public int Combo { get; } 14 | 15 | public int Count300 { get; } 16 | 17 | public int Count100 { get; } 18 | 19 | public int Count50 { get; } 20 | 21 | public int CountMiss { get; } 22 | 23 | public double Accuracy => 24 | (50 * Count50 + 100 * Count100 + 300 * Count300) / 25 | (300.0 * (Count50 + Count100 + Count300 + CountMiss)); 26 | 27 | public double PerformancePoints { get; } 28 | 29 | public Play(string playerId, string beatmapId, Mods mods, PlayRank rank, int combo, int count300, 30 | int count100, int count50, int countMiss, double performancePoints) 31 | { 32 | PlayerId = playerId; 33 | BeatmapId = beatmapId; 34 | Mods = mods; 35 | Rank = rank; 36 | Combo = combo; 37 | Count300 = count300; 38 | Count100 = count100; 39 | Count50 = count50; 40 | CountMiss = countMiss; 41 | PerformancePoints = performancePoints; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /OsuHelper/Models/PlayRank.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable InconsistentNaming (not my fault they're all caps) 2 | 3 | namespace OsuHelper.Models 4 | { 5 | public enum PlayRank 6 | { 7 | D = 0, 8 | C = 1, 9 | B = 2, 10 | A = 3, 11 | S = 4, 12 | SS = 5, 13 | X = SS, 14 | SH = 6, 15 | SSH = 7, 16 | XH = SSH 17 | } 18 | } -------------------------------------------------------------------------------- /OsuHelper/Models/Recommendation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OsuHelper.Models 4 | { 5 | public class Recommendation 6 | { 7 | public Beatmap Beatmap { get; } 8 | 9 | public int Weight { get; } 10 | 11 | public Mods Mods { get; } 12 | 13 | public BeatmapTraits TraitsWithMods { get; } 14 | 15 | public bool IsDurationAffected => Math.Abs((Beatmap.Traits.Duration - TraitsWithMods.Duration).TotalSeconds) >= 0.01; 16 | 17 | public bool IsTempoAffected => Math.Abs(Beatmap.Traits.Tempo - TraitsWithMods.Tempo) >= 0.01; 18 | 19 | public bool IsStarRatingAffected => Math.Abs(Beatmap.Traits.StarRating - TraitsWithMods.StarRating) >= 0.01; 20 | 21 | public bool IsApproachRateAffected => Math.Abs(Beatmap.Traits.ApproachRate - TraitsWithMods.ApproachRate) >= 0.01; 22 | 23 | public bool IsOverallDifficultyAffected => Math.Abs(Beatmap.Traits.OverallDifficulty - TraitsWithMods.OverallDifficulty) >= 0.01; 24 | 25 | public bool IsCircleSizeAffected => Math.Abs(Beatmap.Traits.CircleSize - TraitsWithMods.CircleSize) >= 0.01; 26 | 27 | public bool IsDrainAffected => Math.Abs(Beatmap.Traits.Drain - TraitsWithMods.Drain) >= 0.01; 28 | 29 | public double ExpectedAccuracy { get; } 30 | 31 | public double ExpectedPerformancePoints { get; } 32 | 33 | public Recommendation(Beatmap beatmap, int weight, Mods mods, BeatmapTraits traitsWithMods, double expectedAccuracy, 34 | double expectedPerformancePoints) 35 | { 36 | Beatmap = beatmap; 37 | Weight = weight; 38 | Mods = mods; 39 | TraitsWithMods = traitsWithMods; 40 | ExpectedAccuracy = expectedAccuracy; 41 | ExpectedPerformancePoints = expectedPerformancePoints; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /OsuHelper/OsuHelper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | osu!helper 6 | true 7 | favicon.ico 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /OsuHelper/Services/AudioService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using NAudio.Wave; 5 | 6 | namespace OsuHelper.Services 7 | { 8 | public class AudioService : IDisposable 9 | { 10 | private readonly SettingsService _settingsService; 11 | 12 | private readonly WaveOutEvent _player = new(); 13 | 14 | private TaskCompletionSource? _playbackTcs; 15 | 16 | public bool IsPlaying => _player.PlaybackState == PlaybackState.Playing; 17 | 18 | public AudioService(SettingsService settingsService) 19 | { 20 | _settingsService = settingsService; 21 | 22 | // Configure player 23 | _player.PlaybackStopped += (sender, args) => _playbackTcs?.TrySetResult(null!); 24 | } 25 | 26 | public async Task PlayAsync(Stream stream) 27 | { 28 | await StopAsync(); 29 | 30 | await using var reader = new Mp3FileReader(stream); 31 | 32 | _playbackTcs = new TaskCompletionSource(); 33 | _player.Init(reader); 34 | _player.Volume = (float) _settingsService.PreviewVolume; 35 | _player.Play(); 36 | 37 | await _playbackTcs.Task; 38 | } 39 | 40 | public async Task StopAsync() 41 | { 42 | if (_playbackTcs == null) 43 | return; 44 | 45 | _player.Stop(); 46 | await _playbackTcs.Task; 47 | } 48 | 49 | public void Dispose() => _player.Dispose(); 50 | } 51 | } -------------------------------------------------------------------------------- /OsuHelper/Services/CacheService.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Newtonsoft.Json; 3 | 4 | namespace OsuHelper.Services 5 | { 6 | public class CacheService 7 | { 8 | private readonly string _cacheDirPath; 9 | 10 | public CacheService() 11 | { 12 | _cacheDirPath = Path.Combine(App.ExecutableDirPath, "Cache"); 13 | } 14 | 15 | private string GetCacheFilePath(string id) 16 | { 17 | Directory.CreateDirectory(_cacheDirPath); 18 | return Path.Combine(_cacheDirPath, $"{id}.ch"); 19 | } 20 | 21 | public void Store(string key, object obj) 22 | { 23 | if (obj is string objStr) 24 | { 25 | Directory.CreateDirectory(_cacheDirPath); 26 | File.WriteAllText(GetCacheFilePath(key), objStr); 27 | } 28 | else if (obj is Stream objStream) 29 | { 30 | Directory.CreateDirectory(_cacheDirPath); 31 | using var output = File.Create(GetCacheFilePath(key)); 32 | objStream.CopyTo(output); 33 | } 34 | else 35 | { 36 | var serialized = JsonConvert.SerializeObject(obj); 37 | Directory.CreateDirectory(_cacheDirPath); 38 | File.WriteAllText(GetCacheFilePath(key), serialized); 39 | } 40 | } 41 | 42 | public T? RetrieveOrDefault(string key, T? defaultValue = default) 43 | { 44 | if (typeof(T) == typeof(string)) 45 | { 46 | if (File.Exists(GetCacheFilePath(key))) 47 | return (T) (object) File.ReadAllText(GetCacheFilePath(key)); 48 | 49 | return defaultValue!; 50 | } 51 | if (typeof(T) == typeof(Stream)) 52 | { 53 | if (File.Exists(GetCacheFilePath(key))) 54 | return (T) (object) File.OpenRead(GetCacheFilePath(key)); 55 | 56 | return defaultValue!; 57 | } 58 | else 59 | { 60 | if (File.Exists(GetCacheFilePath(key))) 61 | { 62 | var serialized = File.ReadAllText(GetCacheFilePath(key)); 63 | return JsonConvert.DeserializeObject(serialized); 64 | } 65 | 66 | return defaultValue!; 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /OsuHelper/Services/DataService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Newtonsoft.Json.Linq; 9 | using OsuHelper.Exceptions; 10 | using OsuHelper.Internal; 11 | using OsuHelper.Models; 12 | using Polly; 13 | using Tyrrrz.Extensions; 14 | 15 | namespace OsuHelper.Services 16 | { 17 | public class DataService : IDisposable 18 | { 19 | private readonly SettingsService _settingsService; 20 | private readonly CacheService _cacheService; 21 | 22 | private readonly HttpClient _httpClient; 23 | private readonly SemaphoreSlim _requestRateSemaphore; 24 | private readonly IAsyncPolicy _requestRetryPolicy; 25 | 26 | private DateTimeOffset _lastRequestInstant; 27 | 28 | // API key is assumed to have been set by now 29 | private string ApiKey => _settingsService.ApiKey!; 30 | 31 | public DataService(SettingsService settingsService, CacheService cacheService) 32 | { 33 | _settingsService = settingsService; 34 | _cacheService = cacheService; 35 | 36 | // Unlock connection limit 37 | ServicePointManager.DefaultConnectionLimit = 999; 38 | 39 | // Set up client 40 | var handler = new HttpClientHandler(); 41 | if (handler.SupportsAutomaticDecompression) 42 | handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; 43 | handler.UseCookies = false; 44 | _httpClient = new HttpClient(handler, true); 45 | _httpClient.DefaultRequestHeaders.Add("User-Agent", $"{App.Name} ({App.GitHubProjectUrl})"); 46 | 47 | // Rate limiting 48 | _requestRateSemaphore = new SemaphoreSlim(1, 1); 49 | _lastRequestInstant = DateTimeOffset.MinValue; 50 | 51 | // Request retry policy 52 | // (osu web server is inconsistent) 53 | _requestRetryPolicy = Policy 54 | .Handle(ex => (int) ex.StatusCode >= 500) 55 | .Or(ex => ex.InnerException is IOException) 56 | .WaitAndRetryAsync(10, _ => TimeSpan.FromSeconds(3)); 57 | } 58 | 59 | private async Task MaintainRateLimitAsync(TimeSpan interval) 60 | { 61 | // Gain lock 62 | await _requestRateSemaphore.WaitAsync(); 63 | 64 | try 65 | { 66 | // Wait until enough time has passed since last request 67 | var timePassedSinceLastRequest = DateTimeOffset.Now - _lastRequestInstant; 68 | var remainingTime = interval - timePassedSinceLastRequest; 69 | if (remainingTime > TimeSpan.Zero) 70 | await Task.Delay(remainingTime); 71 | 72 | _lastRequestInstant = DateTimeOffset.Now; 73 | } 74 | finally 75 | { 76 | // Release the lock 77 | _requestRateSemaphore.Release(); 78 | } 79 | } 80 | 81 | private async Task InternalSendRequestAsync(HttpRequestMessage request) 82 | { 83 | // Rate limiting 84 | await MaintainRateLimitAsync(TimeSpan.FromMinutes(1.0 / 500)); 85 | 86 | // Get response 87 | var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); 88 | 89 | // Check status code 90 | // We throw our own exception here because default one doesn't have status code 91 | if (!response.IsSuccessStatusCode) 92 | throw new HttpErrorStatusCodeException(response.StatusCode); 93 | 94 | // Get content 95 | return response; 96 | } 97 | 98 | private async Task GetStringAsync(string url) 99 | { 100 | return await _requestRetryPolicy.ExecuteAsync(async () => 101 | { 102 | using var request = new HttpRequestMessage(HttpMethod.Get, url); 103 | using var response = await InternalSendRequestAsync(request); 104 | 105 | return await response.Content.ReadAsStringAsync(); 106 | }); 107 | } 108 | 109 | private async Task GetStreamAsync(string url) 110 | { 111 | return await _requestRetryPolicy.ExecuteAsync(async () => 112 | { 113 | using var request = new HttpRequestMessage(HttpMethod.Get, url); 114 | var response = await InternalSendRequestAsync(request); 115 | 116 | return await response.Content.ReadAsStreamAsync(); 117 | }); 118 | } 119 | 120 | private async Task GetJsonAsync(string url) 121 | { 122 | var raw = await GetStringAsync(url); 123 | return JToken.Parse(raw); 124 | } 125 | 126 | public async Task GetBeatmapAsync(string beatmapId, GameMode gameMode) 127 | { 128 | // Try to get from cache first 129 | var cached = _cacheService.RetrieveOrDefault($"Beatmap-{beatmapId}"); 130 | if (cached != null) 131 | return cached; 132 | 133 | // Get 134 | var url = $"https://osu.ppy.sh/api/get_beatmaps?k={ApiKey}&m={(int) gameMode}&b={beatmapId}&limit=1&a=1"; 135 | var responseJson = await GetJsonAsync(url); 136 | 137 | // Extract data 138 | var beatmapJson = responseJson.First!; 139 | var id = beatmapJson["beatmap_id"]!.Value()!; 140 | var setId = beatmapJson["beatmapset_id"]!.Value()!; 141 | var creator = beatmapJson["creator"]!.Value()!; 142 | var lastUpdate = beatmapJson["last_update"]!.Value().ToDateTimeOffset(); 143 | var artist = beatmapJson["artist"]!.Value()!; 144 | var title = beatmapJson["title"]!.Value()!; 145 | var version = beatmapJson["version"]!.Value()!; 146 | var maxCombo = beatmapJson["max_combo"]!.Value() ?? 0; // can be null sometimes 147 | var duration = TimeSpan.FromSeconds(beatmapJson["hit_length"]!.Value()); 148 | var bpm = beatmapJson["bpm"]!.Value(); 149 | var sr = beatmapJson["difficultyrating"]!.Value(); 150 | var ar = beatmapJson["diff_approach"]!.Value(); 151 | var od = beatmapJson["diff_overall"]!.Value(); 152 | var cs = beatmapJson["diff_size"]!.Value(); 153 | var hp = beatmapJson["diff_drain"]!.Value(); 154 | 155 | var traits = new BeatmapTraits(maxCombo, duration, bpm, sr, ar, od, cs, hp); 156 | var result = new Beatmap(id, setId, gameMode, creator, lastUpdate, artist, title, version, traits); 157 | 158 | // Save to cache 159 | _cacheService.Store($"Beatmap-{beatmapId}", result); 160 | 161 | return result; 162 | } 163 | 164 | public async Task GetBeatmapSetPreviewAsync(string mapSetId) 165 | { 166 | // Try get from cache first 167 | var cached = _cacheService.RetrieveOrDefault($"BeatmapPreview-{mapSetId}"); 168 | if (cached != null) 169 | return cached; 170 | 171 | // Get 172 | var url = $"https://b.ppy.sh/preview/{mapSetId}.mp3"; 173 | var response = await GetStreamAsync(url); 174 | 175 | // Save to cache 176 | _cacheService.Store($"BeatmapPreview-{mapSetId}", response); 177 | 178 | // Load from cache because HTTP stream cannot seek 179 | return _cacheService.RetrieveOrDefault($"BeatmapPreview-{mapSetId}")!; 180 | } 181 | 182 | public async Task> GetUserTopPlaysAsync(string userId, GameMode gameMode) 183 | { 184 | // Don't cache volatile data 185 | 186 | // Get 187 | var userIdEncoded = WebUtility.UrlEncode(userId); 188 | var url = $"https://osu.ppy.sh/api/get_user_best?k={ApiKey}&m={(int) gameMode}&u={userIdEncoded}&limit=100"; 189 | var responseJson = await GetJsonAsync(url); 190 | 191 | // Extract data 192 | var result = new List(); 193 | foreach (var playJson in responseJson) 194 | { 195 | var playerId = playJson["user_id"]!.Value()!; 196 | var mapId = playJson["beatmap_id"]!.Value()!; 197 | var mods = (Mods) playJson["enabled_mods"]!.Value(); 198 | var rank = playJson["rank"]!.Value()!.ParseEnum(); 199 | var combo = playJson["maxcombo"]!.Value(); 200 | var count300 = playJson["count300"]!.Value(); 201 | var count100 = playJson["count100"]!.Value(); 202 | var count50 = playJson["count50"]!.Value(); 203 | var countMiss = playJson["countmiss"]!.Value(); 204 | var pp = playJson["pp"]!.Value(); 205 | 206 | var play = new Play(playerId, mapId, mods, rank, combo, count300, count100, count50, countMiss, pp); 207 | result.Add(play); 208 | } 209 | 210 | return result; 211 | } 212 | 213 | public async Task> GetBeatmapTopPlaysAsync(string beatmapId, GameMode gameMode, Mods mods) 214 | { 215 | // Don't cache volatile data 216 | 217 | // Get 218 | var url = $"https://osu.ppy.sh/api/get_scores?k={ApiKey}&m={(int) gameMode}&b={beatmapId}&limit=100"; 219 | var responseJson = await GetJsonAsync(url); 220 | 221 | // Extract data 222 | var result = new List(); 223 | foreach (var playJson in responseJson) 224 | { 225 | var playerId = playJson["user_id"]!.Value()!; 226 | var rank = playJson["rank"]!.Value()!.ParseEnum(); 227 | var combo = playJson["maxcombo"]!.Value(); 228 | var count300 = playJson["count300"]!.Value(); 229 | var count100 = playJson["count100"]!.Value(); 230 | var count50 = playJson["count50"]!.Value(); 231 | var countMiss = playJson["countmiss"]!.Value(); 232 | var pp = playJson["pp"]!.Value(); 233 | 234 | var play = new Play(playerId, beatmapId, mods, rank, combo, count300, count100, count50, countMiss, pp); 235 | result.Add(play); 236 | } 237 | 238 | return result; 239 | } 240 | 241 | public void Dispose() 242 | { 243 | _httpClient.Dispose(); 244 | _requestRateSemaphore.Dispose(); 245 | } 246 | } 247 | } -------------------------------------------------------------------------------- /OsuHelper/Services/RecommendationService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using OsuHelper.Exceptions; 6 | using OsuHelper.Logic; 7 | using OsuHelper.Models; 8 | using Tyrrrz.Extensions; 9 | 10 | namespace OsuHelper.Services 11 | { 12 | public class RecommendationService 13 | { 14 | private readonly SettingsService _settingsService; 15 | private readonly DataService _dataService; 16 | 17 | // User ID is assumed to have been set by now 18 | private string UserId => _settingsService.UserId!; 19 | private GameMode GameMode => _settingsService.GameMode; 20 | 21 | public RecommendationService(SettingsService settingsService, DataService dataService) 22 | { 23 | _settingsService = settingsService; 24 | _dataService = dataService; 25 | } 26 | 27 | public async Task> GetRecommendationsAsync(IProgress progressHandler) 28 | { 29 | var progress = 0.0; 30 | progressHandler.Report(progress); 31 | 32 | // Get user's top plays 33 | var ownTopPlays = (await _dataService.GetUserTopPlaysAsync(UserId, GameMode)) 34 | .OrderByDescending(p => p.PerformancePoints) // sort by PP 35 | .ToArray(); 36 | 37 | // Get user's top maps 38 | var ownTopPlaysBeatmapIds = ownTopPlays.Select(p => p.BeatmapId).ToArray(); 39 | 40 | // Truncate user's top plays 41 | ownTopPlays = ownTopPlays.Take(30).ToArray(); 42 | 43 | // If user doesn't have any plays - throw 44 | if (!ownTopPlays.Any()) 45 | throw new RecommendationsUnavailableException($"User [{UserId}] doesn't have any top plays in [{GameMode}]."); 46 | 47 | // Set boundaries for recommendations based on PP 48 | var minPP = ownTopPlays.Average(p => p.PerformancePoints); 49 | var maxPP = minPP * 1.25; 50 | 51 | // Prepare buffer for plays which will serve as base for recommendations 52 | var candidatePlays = new List(); 53 | 54 | // Go through user's top plays 55 | await ownTopPlays.ParallelForEachAsync(async ownTopPlay => 56 | { 57 | // Get the map's top plays 58 | var mapTopPlays = 59 | (await _dataService.GetBeatmapTopPlaysAsync(ownTopPlay.BeatmapId, GameMode, ownTopPlay.Mods)) 60 | .OrderBy(p => Math.Abs(p.PerformancePoints - ownTopPlay.PerformancePoints)) // order by PP similarity 61 | .Take(20) // only take top 20 62 | .ToArray(); 63 | 64 | // Progress 65 | progressHandler.Report(progress += 0.05 / ownTopPlays.Length); 66 | 67 | // Go through those top plays 68 | await mapTopPlays.ParallelForEachAsync(async mapTopPlay => 69 | { 70 | // Get top plays of that user 71 | var otherUserTopPlays = (await _dataService.GetUserTopPlaysAsync(mapTopPlay.PlayerId, GameMode)) 72 | .Where(p => p.Rank >= PlayRank.S) // only S ranks 73 | .Where(p => p.PerformancePoints >= minPP) // limit by minPP 74 | .Where(p => p.PerformancePoints <= maxPP) // limit by maxPP 75 | .OrderBy(p => Math.Abs(p.PerformancePoints - ownTopPlay.PerformancePoints)) // order by PP similarity 76 | .Take(20); // only take top 20 77 | 78 | // Add these plays to candidates 79 | candidatePlays.AddRange(otherUserTopPlays); 80 | 81 | // Progress 82 | progressHandler.Report(progress += 0.85 / mapTopPlays.Length / ownTopPlays.Length); 83 | }); 84 | }); 85 | 86 | // Group candidate plays by beatmap 87 | var candidatePlaysGroups = candidatePlays 88 | .GroupBy(p => p.BeatmapId) // group 89 | .Where(g => !ownTopPlaysBeatmapIds.Contains(g.Key)) // filter out maps that the user has top plays on 90 | .OrderByDescending(g => g.Count()) // sort by number of times the map appears in candidate plays 91 | .Take(200) // only take top 200 92 | .ToArray(); 93 | 94 | // Assemble recommendations 95 | var result = new List(); 96 | await candidatePlaysGroups.ParallelForEachAsync(async group => 97 | { 98 | var count = group.Count(); 99 | 100 | // Get median play based on PP 101 | var play = group.OrderBy(p => p.PerformancePoints).ElementAt(count / 2); 102 | 103 | // Get beatmap data 104 | var beatmap = await _dataService.GetBeatmapAsync(play.BeatmapId, GameMode); 105 | 106 | // Calculate traits with mods 107 | var traitsWithMods = BeatmapTraitsLogic.CalculateTraitsWithMods(beatmap.Traits, play.Mods, GameMode); 108 | 109 | // Add recommendation to the list 110 | var recommendation = new Recommendation(beatmap, count, play.Mods, traitsWithMods, play.Accuracy, play.PerformancePoints); 111 | result.Add(recommendation); 112 | 113 | // Progress 114 | progressHandler.Report(progress += 0.1 / candidatePlaysGroups.Length); 115 | }); 116 | 117 | // Return recommendations sorted by weight 118 | return result.OrderByDescending(r => r.Weight).ToArray(); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /OsuHelper/Services/SettingsService.cs: -------------------------------------------------------------------------------- 1 | using OsuHelper.Models; 2 | using Tyrrrz.Settings; 3 | 4 | namespace OsuHelper.Services 5 | { 6 | public class SettingsService : SettingsManager 7 | { 8 | public string? UserId { get; set; } 9 | 10 | public string? ApiKey { get; set; } 11 | 12 | public GameMode GameMode { get; set; } = GameMode.Standard; 13 | 14 | public bool DownloadWithoutVideo { get; set; } 15 | 16 | public double PreviewVolume { get; set; } = 0.75; 17 | 18 | public bool IsAutoUpdateEnabled { get; set; } = true; 19 | 20 | public SettingsService() 21 | { 22 | Configuration.FileName = "Config.dat"; 23 | Configuration.SubDirectoryPath = ""; 24 | Configuration.StorageSpace = StorageSpace.Instance; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /OsuHelper/Services/UpdateService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Onova; 4 | using Onova.Exceptions; 5 | using Onova.Services; 6 | 7 | namespace OsuHelper.Services 8 | { 9 | public class UpdateService : IDisposable 10 | { 11 | private readonly IUpdateManager _updateManager = new UpdateManager( 12 | new GithubPackageResolver("Tyrrrz", "OsuHelper", "OsuHelper.zip"), 13 | new ZipPackageExtractor()); 14 | 15 | private readonly SettingsService _settingsService; 16 | 17 | private Version? _updateVersion; 18 | private bool _updatePrepared; 19 | private bool _updaterLaunched; 20 | 21 | public UpdateService(SettingsService settingsService) 22 | { 23 | _settingsService = settingsService; 24 | } 25 | 26 | public async Task CheckForUpdatesAsync() 27 | { 28 | if (!_settingsService.IsAutoUpdateEnabled) 29 | return null; 30 | 31 | var check = await _updateManager.CheckForUpdatesAsync(); 32 | return check.CanUpdate ? check.LastVersion : null; 33 | } 34 | 35 | public async Task PrepareUpdateAsync(Version version) 36 | { 37 | if (!_settingsService.IsAutoUpdateEnabled) 38 | return; 39 | 40 | try 41 | { 42 | await _updateManager.PrepareUpdateAsync(_updateVersion = version); 43 | _updatePrepared = true; 44 | } 45 | catch (UpdaterAlreadyLaunchedException) 46 | { 47 | // Ignore race conditions 48 | } 49 | catch (LockFileNotAcquiredException) 50 | { 51 | // Ignore race conditions 52 | } 53 | } 54 | 55 | public void FinalizeUpdate(bool needRestart) 56 | { 57 | if (!_settingsService.IsAutoUpdateEnabled) 58 | return; 59 | 60 | if (_updateVersion == null || !_updatePrepared || _updaterLaunched) 61 | return; 62 | 63 | try 64 | { 65 | _updateManager.LaunchUpdater(_updateVersion, needRestart); 66 | _updaterLaunched = true; 67 | } 68 | catch (UpdaterAlreadyLaunchedException) 69 | { 70 | // Ignore race conditions 71 | } 72 | catch (LockFileNotAcquiredException) 73 | { 74 | // Ignore race conditions 75 | } 76 | } 77 | 78 | public void Dispose() => _updateManager.Dispose(); 79 | } 80 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Dialogs/BeatmapDetailsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using OsuHelper.Exceptions; 3 | using OsuHelper.Internal; 4 | using OsuHelper.Models; 5 | using OsuHelper.Services; 6 | using OsuHelper.ViewModels.Framework; 7 | 8 | namespace OsuHelper.ViewModels.Dialogs 9 | { 10 | public class BeatmapDetailsViewModel : DialogScreen 11 | { 12 | private readonly SettingsService _settingsService; 13 | private readonly DataService _dataService; 14 | private readonly AudioService _audioService; 15 | 16 | public Beatmap? Beatmap { get; set; } 17 | 18 | public bool IsPreviewPlaying { get; private set; } 19 | 20 | public BeatmapDetailsViewModel(SettingsService settingsService, DataService dataService, 21 | AudioService audioService) 22 | { 23 | _settingsService = settingsService; 24 | _dataService = dataService; 25 | _audioService = audioService; 26 | } 27 | 28 | public void OpenPage() => ProcessEx.StartShellExecute($"https://osu.ppy.sh/beatmaps/{Beatmap!.Id}"); 29 | 30 | public void Download() 31 | { 32 | var url = $"https://osu.ppy.sh/beatmapsets/{Beatmap!.MapSetId}/download"; 33 | 34 | // If configured to download without video - append a parameter to the request 35 | if (_settingsService.DownloadWithoutVideo) 36 | url += "?noVideo=1"; 37 | 38 | ProcessEx.StartShellExecute(url); 39 | } 40 | 41 | public void DownloadDirect() => ProcessEx.StartShellExecute($"osu://dl/{Beatmap!.MapSetId}"); 42 | 43 | public void DownloadBloodcat() => ProcessEx.StartShellExecute($"http://bloodcat.com/osu/s/{Beatmap!.MapSetId}"); 44 | 45 | public bool CanPlayPreview => !IsPreviewPlaying; 46 | 47 | public async void PlayPreview() 48 | { 49 | IsPreviewPlaying = true; 50 | 51 | try 52 | { 53 | await using var stream = await _dataService.GetBeatmapSetPreviewAsync(Beatmap!.MapSetId); 54 | await _audioService.PlayAsync(stream); 55 | } 56 | catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden) 57 | { 58 | // Preview not available 59 | } 60 | finally 61 | { 62 | IsPreviewPlaying = false; 63 | } 64 | } 65 | 66 | public bool CanStopPreview => IsPreviewPlaying; 67 | 68 | public async void StopPreview() 69 | { 70 | await _audioService.StopAsync(); 71 | IsPreviewPlaying = false; 72 | } 73 | 74 | public void TogglePreview() 75 | { 76 | if (IsPreviewPlaying) 77 | StopPreview(); 78 | else 79 | PlayPreview(); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Dialogs/SettingsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | using OsuHelper.Internal; 6 | using OsuHelper.Models; 7 | using OsuHelper.Services; 8 | using OsuHelper.ViewModels.Framework; 9 | using Tyrrrz.Extensions; 10 | 11 | namespace OsuHelper.ViewModels.Dialogs 12 | { 13 | public class SettingsViewModel : DialogScreen 14 | { 15 | private readonly SettingsService _settingsService; 16 | 17 | public string? UserId 18 | { 19 | get => _settingsService.UserId; 20 | set 21 | { 22 | if (value != null) 23 | { 24 | var fromUrl = Regex.Match(value, @".*?.ppy.sh/\w/([\w\d]+)").Groups[1].Value; 25 | _settingsService.UserId = !string.IsNullOrWhiteSpace(fromUrl) ? fromUrl : value; 26 | } 27 | else 28 | { 29 | _settingsService.UserId = null; 30 | } 31 | } 32 | } 33 | 34 | public string? ApiKey 35 | { 36 | get => _settingsService.ApiKey; 37 | set => _settingsService.ApiKey = value; 38 | } 39 | 40 | public IReadOnlyList AvailableGameModes { get; } = 41 | Enum.GetValues(typeof(GameMode)).Cast().ToArray(); 42 | 43 | public GameMode GameMode 44 | { 45 | get => _settingsService.GameMode; 46 | set => _settingsService.GameMode = value; 47 | } 48 | 49 | public bool DownloadWithoutVideo 50 | { 51 | get => _settingsService.DownloadWithoutVideo; 52 | set => _settingsService.DownloadWithoutVideo = value; 53 | } 54 | 55 | public double PreviewVolume 56 | { 57 | get => _settingsService.PreviewVolume; 58 | set => _settingsService.PreviewVolume = value.Clamp(0, 1); 59 | } 60 | 61 | public bool IsAutoUpdateEnabled 62 | { 63 | get => _settingsService.IsAutoUpdateEnabled; 64 | set => _settingsService.IsAutoUpdateEnabled = value; 65 | } 66 | 67 | public SettingsViewModel(SettingsService settingsService) 68 | { 69 | _settingsService = settingsService; 70 | } 71 | 72 | public void ObtainApiKey() => ProcessEx.StartShellExecute("https://osu.ppy.sh/p/api"); 73 | } 74 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Framework/DialogManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using MaterialDesignThemes.Wpf; 4 | using Stylet; 5 | 6 | namespace OsuHelper.ViewModels.Framework 7 | { 8 | public class DialogManager 9 | { 10 | private readonly IViewManager _viewManager; 11 | 12 | public DialogManager(IViewManager viewManager) 13 | { 14 | _viewManager = viewManager; 15 | } 16 | 17 | public async Task ShowDialogAsync(DialogScreen dialogScreen) 18 | { 19 | var view = _viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen); 20 | 21 | void OnDialogOpened(object? sender, DialogOpenedEventArgs openArgs) 22 | { 23 | void OnScreenClosed(object? o, EventArgs closeArgs) 24 | { 25 | openArgs.Session.Close(); 26 | dialogScreen.Closed -= OnScreenClosed; 27 | } 28 | 29 | dialogScreen.Closed += OnScreenClosed; 30 | } 31 | 32 | await DialogHost.Show(view, OnDialogOpened); 33 | 34 | return dialogScreen.DialogResult; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Framework/DialogScreen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Stylet; 3 | 4 | namespace OsuHelper.ViewModels.Framework 5 | { 6 | public abstract class DialogScreen : PropertyChangedBase 7 | { 8 | public T? DialogResult { get; private set; } 9 | 10 | public event EventHandler? Closed; 11 | 12 | public void Close(T dialogResult) 13 | { 14 | DialogResult = dialogResult; 15 | Closed?.Invoke(this, EventArgs.Empty); 16 | } 17 | } 18 | 19 | public abstract class DialogScreen : DialogScreen 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Framework/Extensions.cs: -------------------------------------------------------------------------------- 1 | using OsuHelper.Models; 2 | using OsuHelper.ViewModels.Dialogs; 3 | 4 | namespace OsuHelper.ViewModels.Framework 5 | { 6 | public static class Extensions 7 | { 8 | public static BeatmapDetailsViewModel CreateBeatmapDetailsViewModel(this IViewModelFactory factory, 9 | Beatmap beatmap) 10 | { 11 | var viewModel = factory.CreateBeatmapDetailsViewModel(); 12 | viewModel.Beatmap = beatmap; 13 | 14 | return viewModel; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/Framework/IViewModelFactory.cs: -------------------------------------------------------------------------------- 1 | using OsuHelper.ViewModels.Dialogs; 2 | 3 | namespace OsuHelper.ViewModels.Framework 4 | { 5 | // Used to instantiate new view models while making use of dependency injection 6 | public interface IViewModelFactory 7 | { 8 | SettingsViewModel CreateSettingsViewModel(); 9 | 10 | BeatmapDetailsViewModel CreateBeatmapDetailsViewModel(); 11 | } 12 | } -------------------------------------------------------------------------------- /OsuHelper/ViewModels/RootViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Threading.Tasks; 5 | using System.Windows.Data; 6 | using Gress; 7 | using MaterialDesignThemes.Wpf; 8 | using OsuHelper.Exceptions; 9 | using OsuHelper.Internal; 10 | using OsuHelper.Models; 11 | using OsuHelper.Services; 12 | using OsuHelper.ViewModels.Framework; 13 | using Stylet; 14 | 15 | namespace OsuHelper.ViewModels 16 | { 17 | public class RootViewModel : Screen 18 | { 19 | private readonly IViewModelFactory _viewModelFactory; 20 | private readonly DialogManager _dialogManager; 21 | private readonly SettingsService _settingsService; 22 | private readonly UpdateService _updateService; 23 | private readonly CacheService _cacheService; 24 | private readonly RecommendationService _recommendationService; 25 | 26 | public ISnackbarMessageQueue Notifications { get; } = new SnackbarMessageQueue(TimeSpan.FromSeconds(5)); 27 | 28 | public IProgressManager ProgressManager { get; } = new ProgressManager(); 29 | 30 | public bool IsBusy { get; private set; } 31 | 32 | public IReadOnlyList? Recommendations { get; private set; } 33 | 34 | public Recommendation? SelectedRecommendation { get; set; } 35 | 36 | public bool IsNomodFilterEnabled { get; set; } = true; 37 | 38 | public bool IsHiddenFilterEnabled { get; set; } = true; 39 | 40 | public bool IsHardRockFilterEnabled { get; set; } = true; 41 | 42 | public bool IsDoubleTimeFilterEnabled { get; set; } = true; 43 | 44 | public bool IsOtherFilterEnabled { get; set; } = true; 45 | 46 | public RootViewModel(IViewModelFactory viewModelFactory, DialogManager dialogManager, 47 | SettingsService settingsService, UpdateService updateService, CacheService cacheService, 48 | RecommendationService recommendationService) 49 | { 50 | _viewModelFactory = viewModelFactory; 51 | _dialogManager = dialogManager; 52 | _settingsService = settingsService; 53 | _updateService = updateService; 54 | _cacheService = cacheService; 55 | _recommendationService = recommendationService; 56 | 57 | // Title 58 | DisplayName = $"{App.Name} v{App.VersionString}"; 59 | 60 | // Update busy state when progress manager changes 61 | ProgressManager.Bind(o => o.IsActive, (sender, args) => IsBusy = ProgressManager.IsActive); 62 | 63 | // Update recommendations view filter when recommendations change 64 | this.Bind(o => o.Recommendations, (sender, args) => UpdateRecommendationsViewFilter()); 65 | 66 | // Update recommendations view filter when filters change 67 | this.Bind(o => o.IsNomodFilterEnabled, (sender, args) => UpdateRecommendationsViewFilter()); 68 | this.Bind(o => o.IsHiddenFilterEnabled, (sender, args) => UpdateRecommendationsViewFilter()); 69 | this.Bind(o => o.IsHardRockFilterEnabled, (sender, args) => UpdateRecommendationsViewFilter()); 70 | this.Bind(o => o.IsDoubleTimeFilterEnabled, (sender, args) => UpdateRecommendationsViewFilter()); 71 | this.Bind(o => o.IsOtherFilterEnabled, (sender, args) => UpdateRecommendationsViewFilter()); 72 | } 73 | 74 | private async Task HandleAutoUpdateAsync() 75 | { 76 | try 77 | { 78 | // Check for updates 79 | var updateVersion = await _updateService.CheckForUpdatesAsync(); 80 | if (updateVersion == null) 81 | return; 82 | 83 | // Notify user of an update and prepare it 84 | Notifications.Enqueue($"Downloading update to {App.Name} v{updateVersion}..."); 85 | await _updateService.PrepareUpdateAsync(updateVersion); 86 | 87 | // Prompt user to install update (otherwise install it when application exits) 88 | Notifications.Enqueue( 89 | "Update has been downloaded and will be installed when you exit", 90 | "INSTALL NOW", () => 91 | { 92 | _updateService.FinalizeUpdate(true); 93 | RequestClose(); 94 | }); 95 | } 96 | catch 97 | { 98 | // Failure to update shouldn't crash the application 99 | Notifications.Enqueue("Failed to perform application update"); 100 | } 101 | } 102 | 103 | protected override async void OnViewLoaded() 104 | { 105 | base.OnViewLoaded(); 106 | 107 | // Load settings 108 | _settingsService.Load(); 109 | 110 | // Load last recommendations 111 | Recommendations = _cacheService.RetrieveOrDefault>("LastRecommendations"); 112 | 113 | // Check and prepare update 114 | await HandleAutoUpdateAsync(); 115 | } 116 | 117 | protected override void OnClose() 118 | { 119 | base.OnClose(); 120 | 121 | // Save settings 122 | _settingsService.Save(); 123 | 124 | // Finalize updates if necessary 125 | _updateService.FinalizeUpdate(false); 126 | } 127 | 128 | private void UpdateRecommendationsViewFilter() 129 | { 130 | var view = CollectionViewSource.GetDefaultView(Recommendations); 131 | if (view == null) 132 | return; 133 | 134 | view.Filter = o => 135 | { 136 | var recommendation = (Recommendation) o; 137 | 138 | var accepted = true; 139 | 140 | if (recommendation.Mods == Mods.None) 141 | accepted &= IsNomodFilterEnabled; 142 | 143 | if (recommendation.Mods.HasFlag(Mods.Hidden)) 144 | accepted &= IsHiddenFilterEnabled; 145 | 146 | if (recommendation.Mods.HasFlag(Mods.HardRock)) 147 | accepted &= IsHardRockFilterEnabled; 148 | 149 | if (recommendation.Mods.HasFlag(Mods.DoubleTime)) 150 | accepted &= IsDoubleTimeFilterEnabled; 151 | 152 | var modsOther = recommendation.Mods & ~Mods.Hidden & ~Mods.HardRock & ~Mods.DoubleTime; 153 | if (modsOther != Mods.None) 154 | accepted &= IsOtherFilterEnabled; 155 | 156 | return accepted; 157 | }; 158 | } 159 | 160 | public bool CanShowSettings => !IsBusy; 161 | 162 | public async void ShowSettings() 163 | { 164 | // Create dialog 165 | var dialog = _viewModelFactory.CreateSettingsViewModel(); 166 | 167 | // Show dialog 168 | await _dialogManager.ShowDialogAsync(dialog); 169 | } 170 | 171 | public bool CanShowBeatmapDetails => SelectedRecommendation != null; 172 | 173 | public async void ShowBeatmapDetails() 174 | { 175 | // HACK: Stylet's event actions don't respect guard properties 176 | if (!CanShowBeatmapDetails) 177 | return; 178 | 179 | // Create dialog 180 | var dialog = _viewModelFactory.CreateBeatmapDetailsViewModel(SelectedRecommendation!.Beatmap); 181 | 182 | // Show dialog 183 | await _dialogManager.ShowDialogAsync(dialog); 184 | } 185 | 186 | public void ShowAbout() => ProcessEx.StartShellExecute(App.GitHubProjectUrl); 187 | 188 | public bool CanPopulateRecommendations => !IsBusy; 189 | 190 | public async void PopulateRecommendations() 191 | { 192 | // Create progress operation 193 | var operation = ProgressManager.CreateOperation(); 194 | 195 | try 196 | { 197 | // Validate settings 198 | if (string.IsNullOrWhiteSpace(_settingsService.UserId) || string.IsNullOrWhiteSpace(_settingsService.ApiKey)) 199 | { 200 | Notifications.Enqueue("Not configured – set username and API key in settings", 201 | "OPEN", ShowSettings); 202 | return; 203 | } 204 | 205 | // Get recommendations 206 | Recommendations = await _recommendationService.GetRecommendationsAsync(operation); 207 | 208 | // Persist recommendations in cache 209 | _cacheService.Store("LastRecommendations", Recommendations); 210 | 211 | // Notify completion 212 | Notifications.Enqueue("Recommendations updated"); 213 | } 214 | catch (RecommendationsUnavailableException) 215 | { 216 | Notifications.Enqueue("Recommendations unavailable – no top plays set in selected game mode"); 217 | } 218 | catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized) 219 | { 220 | Notifications.Enqueue("Unauthorized – make sure API key is valid"); 221 | } 222 | finally 223 | { 224 | // Dispose progress operation 225 | operation.Dispose(); 226 | } 227 | } 228 | } 229 | } -------------------------------------------------------------------------------- /OsuHelper/Views/Dialogs/BeatmapDetailsView.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 70 | 71 | 72 | 88 | 89 | 90 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /OsuHelper/Views/Dialogs/BeatmapDetailsView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace OsuHelper.Views.Dialogs 2 | { 3 | public partial class BeatmapDetailsView 4 | { 5 | public BeatmapDetailsView() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /OsuHelper/Views/Dialogs/SettingsView.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 21 | 22 | 23 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 44 | 48 | 49 | 50 | 51 | 52 | 56 | 64 | 65 | 66 | 67 | 68 | 72 | 76 | 77 | 78 | 79 | 80 | 81 | Generate API key 82 | 83 | 84 | 85 | 109 | 121 | 138 | 139 | 140 | 141 | 142 | 146 | 147 | 148 | 149 | 150 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 171 | 172 | 173 | 176 | 177 | 178 | 179 | 180 | 184 | 185 | 186 | 187 | 188 | 189 | 196 | 197 | 198 | 199 | 200 | 201 | 208 | 209 | 210 | 211 | 212 | 213 | 220 | 221 | 222 | 223 | 224 | 225 | 232 | 233 | 234 | 235 | 236 | 237 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /OsuHelper/Views/RootView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace OsuHelper.Views 2 | { 3 | public partial class RootView 4 | { 5 | public RootView() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /OsuHelper/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tyrrrz/OsuHelper/b2dfa895272e1d58780eab84097afeac50ddf4f1/OsuHelper/favicon.ico -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # osu!helper 2 | 3 | [![Status](https://img.shields.io/badge/status-discontinued-e4181c.svg)](https://github.com/Tyrrrz/.github/blob/master/docs/project-status.md) 4 | [![Build](https://github.com/Tyrrrz/OsuHelper/workflows/CI/badge.svg?branch=master)](https://github.com/Tyrrrz/OsuHelper/actions) 5 | [![Release](https://img.shields.io/github/release/Tyrrrz/OsuHelper.svg)](https://github.com/Tyrrrz/OsuHelper/releases) 6 | [![Downloads](https://img.shields.io/github/downloads/Tyrrrz/OsuHelper/total.svg)](https://github.com/Tyrrrz/OsuHelper/releases) 7 | 8 | 9 | 10 | 11 | 12 |
Development of this project is entirely funded by the community. Consider donating to support!
13 | 14 | osu!helper is an application that recommends beatmaps in osu! based on your current performance. It searches for players who did similarly well on maps you've played in the past and uses their top plays as basis for recommendation. The recommended maps are then displayed in a grid where users are able to see the map's attributes adjusted by the suggested mods, as well as some other useful information. Maps can also be previewed and downloaded straight from the application. 15 | 16 | ## Download 17 | 18 | - **[Latest release](https://github.com/Tyrrrz/OsuHelper/releases/latest)** 19 | - [CI build](https://github.com/Tyrrrz/OsuHelper/actions) 20 | 21 | ## Features 22 | 23 | - Get recommendations in large batches 24 | - Filter results by mods 25 | - Beatmap stats at a glance, adjusted by mods 26 | - Recommendations are weighted by beatmap's statistical difficulty 27 | - Download or preview beatmaps straight from application 28 | - Supports all game modes 29 | 30 | ## Screenshots 31 | 32 | ![list](.screenshots/list.png) 33 | ![beatmap](.screenshots/beatmap.png) 34 | --------------------------------------------------------------------------------