├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── ci-check.yml ├── .gitignore ├── .gitmodules ├── .vscode ├── launch.json └── tasks.json ├── LICENSE ├── README.md ├── assets ├── banner.png ├── screenshot_gameplay.png ├── screenshot_gameplay2.png └── screenshot_selection.png ├── build.config ├── build.ps1 ├── build.sh ├── build ├── Build.csproj ├── Context.cs ├── Lifetime.cs ├── Program.cs ├── ReleaseHeader.md └── Tasks │ ├── BuildRelease.cs │ ├── Default.cs │ ├── FetchLazerVersion.cs │ ├── RestoreProject.cs │ └── UploadRelease.cs ├── osu.Game.Rulesets.Gamebosu.Tests ├── .vscode │ ├── launch.json │ └── tasks.json ├── Screens │ ├── Listing │ │ └── TestSceneListingSubScreen.cs │ ├── Selection │ │ ├── TestSceneGamebosuSelectionScreen.cs │ │ └── TestSceneRomSelector.cs │ ├── TestSceneGamebosuDisclaimerSubScreen.cs │ └── TestSceneGamebosuScreenStack.cs ├── TestSceneClockRateIndicator.cs ├── TestSceneGameboyClock.cs ├── TestSceneOsuGame.cs ├── VisualTestRunner.cs └── osu.Game.Rulesets.Gamebosu.Tests.csproj ├── osu.Game.Rulesets.Gamebosu.sln ├── osu.Game.Rulesets.Gamebosu.sln.DotSettings ├── osu.Game.Rulesets.Gamebosu.sln.licenseheader └── osu.Game.Rulesets.Gamebosu ├── Audio ├── BASSAudioChannelOutput.cs └── CircularBuffer.cs ├── Beatmaps └── GamebosuBeatmapConverter.cs ├── Configuration └── GamebosuConfigManager.cs ├── FodyWeavers.xml ├── GamebosuDifficultyCalculator.cs ├── GamebosuRuleset.cs ├── Graphics ├── GamebosuToolbarIcon.cs ├── RulesetIcon.cs └── ScrollingSpriteText.cs ├── IO └── RomStore.cs ├── Objects ├── Drawables │ └── DrawableGamebosuHitObject.cs └── GamebosuHitObject.cs ├── Replays ├── GamebosuFramedReplayInputHandler.cs └── GamebosuReplayFrame.cs ├── Resources └── Textures │ ├── cartridge.png │ ├── dmg_sprite.png │ ├── emu_crash.png │ ├── emu_went_brrr.png │ ├── gamebosu_toolbar.png │ ├── logo.png │ └── logo_pixelated.png ├── UI ├── Configuration │ ├── DeleteDataDialog.cs │ ├── DeleteDataErrorDialog.cs │ └── GamebosuSettingsSubsection.cs ├── DrawableGamebosuRuleset.cs ├── GamebosuPlayfield.cs ├── Gameboy │ ├── CrashScreenCover.cs │ ├── DrawableGameboy.cs │ ├── DrawableGameboyClock.cs │ ├── DrawableGameboyScreen.cs │ └── SpanTextureUpload.cs ├── Input │ ├── GamebosuAction.cs │ └── GamebosuInputManager.cs └── Screens │ ├── DisclaimerSubScreen.cs │ ├── GamebosuMainScreen.cs │ ├── GamebosuScreenStack.cs │ ├── GamebosuSubScreen.cs │ ├── Gameplay │ ├── ClockRateIndicator.cs │ ├── ClockRateIndicatorControlReceptor.cs │ └── ValueGauge.cs │ ├── GameplaySubScreen.cs │ ├── Listing │ ├── ListingHeader.cs │ ├── ListingPanel.cs │ ├── NoRomAvailablePopup.cs │ ├── RomImportHandler.cs │ └── RomListing.cs │ ├── ListingSubScreen.cs │ ├── MovingNotice.cs │ ├── RomSelectionSubScreen.cs │ ├── ScreenWithCyclingBeatmapBackground.cs │ └── Selection │ ├── NoRomAvailableMessage.cs │ ├── RomSelector.cs │ └── SelectionCard.cs ├── Utils ├── StartupTaskAttribute.cs ├── StartupTaskQueue.cs └── UIInjectionHooks.cs └── osu.Game.Rulesets.Gamebosu.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: ppy.osu.Game 11 | versions: 12 | - 2021.127.0 13 | - 2021.226.0 14 | - dependency-name: NUnit 15 | versions: 16 | - 3.13.1 17 | -------------------------------------------------------------------------------- /.github/workflows/ci-check.yml: -------------------------------------------------------------------------------- 1 | name: CI Compile checks 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | Build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout repository 10 | uses: actions/checkout@v3 11 | 12 | - name: Checkout emux submodule 13 | run: git submodule update --init --recursive 14 | 15 | - name: Setup .NET 16 | uses: actions/setup-dotnet@v2 17 | with: 18 | dotnet-version: 8.0.x 19 | 20 | - name: Compile project 21 | run: dotnet build -c release osu.Game.Rulesets.Gamebosu.sln 22 | 23 | - name: Upload Build Artifact 24 | uses: actions/upload-artifact@v3.1.0 25 | with: 26 | name: osu.Game.Rulesets.Gamebosu.dll 27 | path: "osu.Game.Rulesets.Gamebosu/bin/Release/netstandard2.1" 28 | retention-days: 30 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb 341 | 342 | FodyWeavers.xsd -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Emux"] 2 | path = Emux 3 | url = https://github.com/Game4all/Emux 4 | branch = handle-game-crash 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/osu.Game.Rulesets.Gamebosu.Tests/bin/Debug/netcoreapp6.0/osu.Game.Rulesets.Gamebosu.Tests.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/osu.Game.Rulesets.Gamebosu.Tests", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/osu.Game.Rulesets.Gamebosu.sln", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/osu.Game.Rulesets.Gamebosu.sln", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/osu.Game.Rulesets.Gamebosu.sln" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) Lucas ARRIESSE aka Game4all 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | A ruleset that adds a playable gameboy to osu!lazer. 6 |
7 | 8 | # **DISCLAIMER** 9 | 10 | This ruleset isn't a serious ruleset and doesn't serve any other purpose than showing the capabilities of the game framework and being cool, and of course useless. Now you're warned ... 11 | 12 | ## Screenshots 13 | ![rom selection](assets/screenshot_selection.png) | ![gameplay](assets/screenshot_gameplay.png)| ![gameplay2](assets/screenshot_gameplay2.png) 14 | |--| --| -- | 15 | 16 | # Installation 17 | 18 | The ruleset consists of a single DLL file that you'll have to drop in the `rulesets` directory of your osu!lazer data directory. 19 | 20 | Prebuilt releases are available if you do not have an development environement setup in place: 21 | | [Releases](https://github.com/Game4all/gamebosu/releases) | [Latest Release](https://github.com/Game4all/gamebosu/releases/latest) 22 | |--------|--------| 23 | 24 | Or you can alternatively build the ruleset yourself by issuing the following commands in your OS shell (_this assumes you've got the .NET Core SDK tools as well as git in your PATH_): 25 | 26 | ## Building instructions 27 | 28 | ```bash 29 | git clone https://github.com/Game4all/gamebosu 30 | cd gamebosu 31 | cd osu.Game.Rulesets.Gamebosu 32 | dotnet build -c:Release # make sure to build ruleset in release mode to create a single file assembly 33 | # You should find the compiled and packed ruleset assembly in the output directory at path bin/Release/netstandard2.1/osu.Game.Rulesets.Gamebosu.dll 34 | ``` 35 | 36 | For building this from an IDE, you should open the solution file with your prefered C# editor and hit `build` with the `Release` configuration (in order to create a single file assembly). 37 | 38 | ## Installation instructions 39 | 40 | 1. Navigate to your osu!lazer data directory. You can do so by opening the settings panel in osu!lazer and clicking on the "open osu! folder" button. Alternatively you can directly navigate to the rulesets directory via your OS directory explorer at the following locations: 41 | 42 | * `%AppData%/osu/rulesets` on Windows 43 | * `~/.local/share/osu/rulesets` on Linux / mac OSX 44 | 45 | **NOTE:** If you have relocated your osu! data directory to another directory, the rulesets directory will be there instead. 46 | 47 | 2. Drag and drop the ruleset's DLL file into the `rulesets` directory. 48 | 49 | 3. Have fun! You may need to head periodically to the releases page to download the latest version of the ruleset as compatibilty may break with a new lazer update. You may want to also read [**Installing Roms**](#Installing-Roms) section before using the ruleset. 50 | 51 | # Installing Roms 52 | 53 | In order for the ruleset to correctly work, you'll need to download original gameboy or gameboy color ROM files and place them in a `roms` directory inside your osu!lazer data directory (you may have to launch the ruleset once in order for the directory to appear.) 54 | 55 | # Acknowledgements 56 | 57 | This ruleset uses [Emux](https://github.com/Washi1337/Emux) by _Washi1337_ as its emulation core. 58 | 59 | Original idea of running a gameboy emulator on o!f : [osu-GameBoy](https://github.com/osu-Karaoke/osu-GameBoy) -------------------------------------------------------------------------------- /assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/assets/banner.png -------------------------------------------------------------------------------- /assets/screenshot_gameplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/assets/screenshot_gameplay.png -------------------------------------------------------------------------------- /assets/screenshot_gameplay2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/assets/screenshot_gameplay2.png -------------------------------------------------------------------------------- /assets/screenshot_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/assets/screenshot_selection.png -------------------------------------------------------------------------------- /build.config: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | DOTNET_VERSION=3.1.402 3 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | $DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1'; 3 | $DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh' 4 | $DotNetChannel = 'LTS' 5 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 6 | 7 | [string] $DotNetVersion= '' 8 | foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config')) 9 | { 10 | if ($line -like 'DOTNET_VERSION=*') { 11 | $DotNetVersion =$line.SubString(15) 12 | } 13 | } 14 | 15 | 16 | if ([string]::IsNullOrEmpty($DotNetVersion)) { 17 | 'Failed to parse .NET Core SDK Version' 18 | exit 1 19 | } 20 | 21 | $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; 22 | 23 | # Make sure tools folder exists 24 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 25 | $ToolPath = Join-Path $PSScriptRoot "tools" 26 | if (!(Test-Path $ToolPath)) { 27 | Write-Verbose "Creating tools directory..." 28 | New-Item -Path $ToolPath -Type directory | out-null 29 | } 30 | 31 | ########################################################################### 32 | # INSTALL .NET CORE CLI 33 | ########################################################################### 34 | 35 | Function Remove-PathVariable([string]$VariableToRemove) 36 | { 37 | $path = [Environment]::GetEnvironmentVariable("PATH", "User") 38 | $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } 39 | [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") 40 | $path = [Environment]::GetEnvironmentVariable("PATH", "Process") 41 | $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } 42 | [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") 43 | } 44 | 45 | # Get .NET Core CLI path if installed. 46 | $FoundDotNetCliVersion = $null; 47 | if (Get-Command dotnet -ErrorAction SilentlyContinue) { 48 | $FoundDotNetCliVersion = dotnet --version; 49 | } 50 | 51 | if($FoundDotNetCliVersion -ne $DotNetVersion) { 52 | $InstallPath = Join-Path $PSScriptRoot ".dotnet" 53 | if (!(Test-Path $InstallPath)) { 54 | mkdir -Force $InstallPath | Out-Null; 55 | } 56 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); 57 | & $InstallPath\dotnet-install.ps1 -Version $DotNetVersion -InstallDir $InstallPath; 58 | 59 | Remove-PathVariable "$InstallPath" 60 | $env:PATH = "$InstallPath;$env:PATH" 61 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 62 | $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 63 | } 64 | 65 | ########################################################################### 66 | # RUN BUILD SCRIPT 67 | ########################################################################### 68 | 69 | dotnet run --project build/Build.csproj -- $args 70 | exit $LASTEXITCODE; -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Define varibles 3 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 4 | source $SCRIPT_DIR/build.config 5 | 6 | if [ "$DOTNET_VERSION" = "" ]; then 7 | echo "An error occured while parsing .NET Core SDK version." 8 | exit 1 9 | fi 10 | 11 | ########################################################################### 12 | # INSTALL .NET CORE CLI 13 | ########################################################################### 14 | 15 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 16 | export DOTNET_CLI_TELEMETRY_OPTOUT=1 17 | export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 18 | export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 19 | 20 | DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1) 21 | 22 | if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then 23 | echo "Installing .NET CLI..." 24 | if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then 25 | mkdir "$SCRIPT_DIR/.dotnet" 26 | fi 27 | curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh 28 | bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path 29 | export PATH="$SCRIPT_DIR/.dotnet":$PATH 30 | export DOTNET_ROOT="$SCRIPT_DIR/.dotnet" 31 | fi 32 | 33 | ########################################################################### 34 | # RUN BUILD SCRIPT 35 | ########################################################################### 36 | 37 | echo "Running build script.." 38 | dotnet run --project ./build/Build.csproj -- "$@" 39 | -------------------------------------------------------------------------------- /build/Build.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | true 7 | 8 | 9 | $(MSBuildProjectDirectory) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /build/Context.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Cake.Core; 3 | using Cake.Frosting; 4 | using System.IO; 5 | 6 | public class Context : FrostingContext 7 | { 8 | private const string ruleset_project_name = "osu.Game.Rulesets.Gamebosu"; 9 | 10 | public string ReleaseVersion => DateTime.Now.ToString("yyyy.Mdd.0"); 11 | 12 | public string ReleaseBodyText => File.ReadAllText("build/ReleaseHeader.md"); 13 | 14 | public string RequiredLazerVersion { get; set; } 15 | 16 | public Context(ICakeContext context) 17 | : base(context) 18 | { 19 | } 20 | 21 | private string ruleset_project_csproj_path => Path.Combine("..\\", ruleset_project_name, ruleset_project_name + ".csproj"); 22 | 23 | public string RulesetProjectPath => Path.Combine(".\\", ruleset_project_name); 24 | 25 | public string RulesetOutputPath => Path.Combine(RulesetProjectPath, "bin/Release/net8.0/osu.Game.Rulesets.Gamebosu.dll"); 26 | } -------------------------------------------------------------------------------- /build/Lifetime.cs: -------------------------------------------------------------------------------- 1 | using Cake.Common.Diagnostics; 2 | using Cake.Core; 3 | using Cake.Frosting; 4 | 5 | public sealed class Lifetime : FrostingLifetime 6 | { 7 | } -------------------------------------------------------------------------------- /build/Program.cs: -------------------------------------------------------------------------------- 1 | using Cake.Core; 2 | using Cake.Frosting; 3 | 4 | public class Program : IFrostingStartup 5 | { 6 | public static int Main(string[] args) 7 | { 8 | // Create the host. 9 | var host = new CakeHostBuilder() 10 | .WithArguments(args) 11 | .UseStartup() 12 | .Build(); 13 | 14 | // Run the host. 15 | return host.Run(); 16 | } 17 | 18 | public void Configure(ICakeServices services) 19 | { 20 | services.UseContext(); 21 | services.UseLifetime(); 22 | services.UseWorkingDirectory(".."); 23 | } 24 | } -------------------------------------------------------------------------------- /build/ReleaseHeader.md: -------------------------------------------------------------------------------- 1 | **Disclaimer: This is still a WIP. As such, things may be missing or broken** 2 | _Please see the [installation instructions](https://github.com/Game4all/gamebosu#installation-instructions) for detailed steps on installing the ruleset_ 3 | 4 | This version should work with osu!lazer **_>=_ {LAZER_VERSION}** 5 | -------------------------------------------------------------------------------- /build/Tasks/BuildRelease.cs: -------------------------------------------------------------------------------- 1 | using Cake.Common.Diagnostics; 2 | using Cake.Common.Tools.DotNetCore; 3 | using Cake.Frosting; 4 | using Cake.Common.Tools.DotNetCore.MSBuild; 5 | using Cake.Common.Tools.DotNetCore.Build; 6 | 7 | [TaskName("BuildRelease")] 8 | [Dependency(typeof(RestoreProject))] 9 | public sealed class BuildRelease : FrostingTask 10 | { 11 | public override void Run(Context context) 12 | { 13 | context.Information("Cleaning previous build artifacts ..."); 14 | 15 | context.DotNetCoreClean(context.RulesetProjectPath); 16 | 17 | context.Information($"Building release version {context.ReleaseVersion}"); 18 | 19 | var msbuildOpts = new DotNetCoreMSBuildSettings(); 20 | msbuildOpts.SetVersion(context.ReleaseVersion); 21 | 22 | var buildOpts = new DotNetCoreBuildSettings { 23 | Configuration = "Release", 24 | MSBuildSettings = msbuildOpts 25 | }; 26 | 27 | context.DotNetCoreBuild(context.RulesetProjectPath, buildOpts); 28 | 29 | context.Information("Release built sucessfully"); 30 | } 31 | } -------------------------------------------------------------------------------- /build/Tasks/Default.cs: -------------------------------------------------------------------------------- 1 | using Cake.Frosting; 2 | 3 | [Dependency(typeof(BuildRelease))] 4 | public sealed class Default : FrostingTask 5 | { 6 | } -------------------------------------------------------------------------------- /build/Tasks/FetchLazerVersion.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using Cake.Common.Diagnostics; 5 | using Cake.Frosting; 6 | 7 | [Dependency(typeof(RestoreProject))] 8 | public sealed class FetchLazerVersion : FrostingTask 9 | { 10 | public override void Run(Context context) 11 | { 12 | var process = Process.Start(new ProcessStartInfo 13 | { 14 | FileName = "dotnet", 15 | Arguments = $"list {context.RulesetProjectPath} package", 16 | RedirectStandardOutput = true 17 | }); 18 | 19 | var output = process.StandardOutput.ReadToEnd(); 20 | 21 | //[0] is package name 22 | //[1] is package version 23 | var parsed_package_version_info = output[(output.IndexOf('>') + 1)..].Split(' ').Where(str => !string.IsNullOrWhiteSpace(str)); 24 | 25 | context.RequiredLazerVersion = parsed_package_version_info.ElementAt(1); 26 | 27 | context.Information($"Lazer version is {context.RequiredLazerVersion}"); 28 | } 29 | } -------------------------------------------------------------------------------- /build/Tasks/RestoreProject.cs: -------------------------------------------------------------------------------- 1 | using Cake.Common.Diagnostics; 2 | using Cake.Common.Tools.DotNetCore; 3 | using Cake.Frosting; 4 | 5 | [TaskName("RestoreProject")] 6 | public sealed class RestoreProject : FrostingTask 7 | { 8 | public override void Run(Context context) 9 | { 10 | context.Information("Restoring project dependencies...."); 11 | context.DotNetCoreRestore(context.RulesetProjectPath); 12 | } 13 | } -------------------------------------------------------------------------------- /build/Tasks/UploadRelease.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Cake.Common; 6 | using Cake.Common.Diagnostics; 7 | using Cake.Frosting; 8 | using Octokit; 9 | 10 | [TaskName("UploadRelease")] 11 | [Dependency(typeof(FetchLazerVersion))] 12 | [Dependency(typeof(BuildRelease))] 13 | public sealed class UploadRelease : FrostingTask 14 | { 15 | public override void Run(Context context) 16 | { 17 | context.Information("Preparing for uploading ..."); 18 | 19 | var token = context.Argument("token"); 20 | var repo = context.Argument("repo"); 21 | var user = context.Argument("user"); 22 | 23 | var client = new GitHubClient(new ProductHeaderValue(repo)); 24 | client.Credentials = new Credentials(token); 25 | 26 | Task.Run(async () => 27 | { 28 | var releases = await client.Repository.Release.GetAll(user, repo); 29 | if (releases.Any(rel => rel.TagName == context.ReleaseVersion)) 30 | { 31 | context.Error("There's already an existing release with the given version number!"); 32 | Environment.FailFast(null); 33 | } 34 | 35 | var release_data = new NewRelease(context.ReleaseVersion) 36 | { 37 | Name = $"{context.ReleaseVersion} release", 38 | Body = context.ReleaseBodyText.Replace("{RELEASE_VERSION}", context.ReleaseVersion) 39 | .Replace("{LAZER_VERSION}", context.RequiredLazerVersion), 40 | }; 41 | 42 | context.Information("Creating release ...."); 43 | 44 | var new_release = await client.Repository.Release.Create(user, repo, release_data); 45 | 46 | context.Information($"Release {context.ReleaseVersion} was created sucessfully!"); 47 | 48 | var file = File.OpenRead(context.RulesetOutputPath); 49 | 50 | context.Information("Uploading asset ....."); 51 | 52 | var upload = new ReleaseAssetUpload("osu.Game.Rulesets.Gamebosu.dll", "application/octet-stream", file, TimeSpan.FromSeconds(120)); 53 | 54 | await client.Repository.Release.UploadAsset(new_release, upload); 55 | 56 | context.Information("Uploaded asset !"); 57 | 58 | }).Wait(); 59 | } 60 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "VisualTests (Debug)", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "program": "dotnet", 9 | "args": [ 10 | "${workspaceRoot}/bin/Debug/netcoreapp3.1/osu.Game.Rulesets.GamebosuRuleset.Tests.dll" 11 | ], 12 | "cwd": "${workspaceRoot}", 13 | "preLaunchTask": "Build (Debug)", 14 | "env": {}, 15 | "console": "internalConsole" 16 | }, 17 | { 18 | "name": "VisualTests (Release)", 19 | "type": "coreclr", 20 | "request": "launch", 21 | "program": "dotnet", 22 | "args": [ 23 | "${workspaceRoot}/bin/Release/netcoreapp3.1/osu.Game.Rulesets.GamebosuRuleset.Tests.dll" 24 | ], 25 | "cwd": "${workspaceRoot}", 26 | "preLaunchTask": "Build (Release)", 27 | "env": {}, 28 | "console": "internalConsole" 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "Build (Debug)", 8 | "type": "shell", 9 | "command": "dotnet", 10 | "args": [ 11 | "build", 12 | "--no-restore", 13 | "osu.Game.Rulesets.GamebosuRuleset.Tests.csproj", 14 | "/p:GenerateFullPaths=true", 15 | "/m", 16 | "/verbosity:m" 17 | ], 18 | "group": "build", 19 | "problemMatcher": "$msCompile" 20 | }, 21 | { 22 | "label": "Build (Release)", 23 | "type": "shell", 24 | "command": "dotnet", 25 | "args": [ 26 | "build", 27 | "--no-restore", 28 | "osu.Game.Rulesets.GamebosuRuleset.Tests.csproj", 29 | "/p:Configuration=Release", 30 | "/p:GenerateFullPaths=true", 31 | "/m", 32 | "/verbosity:m" 33 | ], 34 | "group": "build", 35 | "problemMatcher": "$msCompile" 36 | }, 37 | { 38 | "label": "Restore", 39 | "type": "shell", 40 | "command": "dotnet", 41 | "args": [ 42 | "restore" 43 | ], 44 | "problemMatcher": [] 45 | } 46 | ] 47 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/Screens/Listing/TestSceneListingSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Tests.Screens.Listing 7 | { 8 | public partial class TestSceneListingSubScreen : TestSceneGamebosuScreenStack 9 | { 10 | protected override GamebosuSubScreen CreateSubScreen() => new ListingSubScreen(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/Screens/Selection/TestSceneGamebosuSelectionScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Tests.Screens.Selection 7 | { 8 | public partial class TestSceneGamebosuSelectionScreen : TestSceneGamebosuScreenStack 9 | { 10 | protected override GamebosuSubScreen CreateSubScreen() => new RomSelectionSubScreen(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/Screens/Selection/TestSceneRomSelector.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using NUnit.Framework; 5 | using osu.Framework.Input.Events; 6 | using osu.Game.Rulesets.Gamebosu.UI.Input; 7 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Selection; 8 | using osu.Game.Tests.Visual; 9 | using System.Linq; 10 | 11 | namespace osu.Game.Rulesets.Gamebosu.Tests.Screens.Selection 12 | { 13 | public partial class TestSceneRomSelector : OsuTestScene 14 | { 15 | private RomSelector romSelector; 16 | 17 | public TestSceneRomSelector() 18 | { 19 | } 20 | 21 | 22 | [SetUp] 23 | public void SetUp() 24 | { 25 | Child = romSelector = new RomSelector() 26 | { 27 | RelativeSizeAxes = Framework.Graphics.Axes.Both 28 | }; 29 | } 30 | 31 | [Test] 32 | public void TestRomSelection() 33 | { 34 | AddStep("add roms", () => 35 | { 36 | var roms = new string[] 37 | { 38 | "rom.gb", 39 | "rom.gba", 40 | "yes.gba", 41 | }; 42 | 43 | romSelector.AvailableRoms.Value = roms; 44 | }); 45 | 46 | AddStep("select next rom", () => romSelector.OnPressed(new KeyBindingPressEvent(new Framework.Input.States.InputState(), GamebosuAction.DPadRight))); 47 | AddStep("go back to previous rom", () => romSelector.OnPressed(new KeyBindingPressEvent(new Framework.Input.States.InputState(), GamebosuAction.DPadLeft))); 48 | AddStep("show rom as unavalaible", () => romSelector.MarkUnavailable()); 49 | AddStep("clear roms", () => romSelector.AvailableRoms.Value = Enumerable.Empty()); 50 | } 51 | 52 | [Test] 53 | public void TestNoRom() 54 | { 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/Screens/TestSceneGamebosuDisclaimerSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Tests.Screens 7 | { 8 | public partial class TestSceneGamebosuDisclaimerSubScreen : TestSceneGamebosuScreenStack 9 | { 10 | protected override GamebosuSubScreen CreateSubScreen() => new DisclaimerSubScreen(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/Screens/TestSceneGamebosuScreenStack.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Testing; 6 | using osu.Game.Configuration; 7 | using osu.Game.Rulesets.Gamebosu.Configuration; 8 | using osu.Game.Rulesets.Gamebosu.IO; 9 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 10 | using osu.Game.Tests.Visual; 11 | 12 | namespace osu.Game.Rulesets.Gamebosu.Tests.Screens 13 | { 14 | public abstract partial class TestSceneGamebosuScreenStack : OsuTestScene 15 | { 16 | protected abstract GamebosuSubScreen CreateSubScreen(); 17 | 18 | protected GamebosuScreenStack Stack { get; private set; } 19 | 20 | protected TestSceneGamebosuScreenStack() 21 | { 22 | Child = Stack = new GamebosuScreenStack(); 23 | } 24 | 25 | [SetUpSteps] 26 | public virtual void SetUpSteps() 27 | { 28 | AddStep("create screen", () => Stack.Push(CreateSubScreen())); 29 | } 30 | 31 | protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) 32 | { 33 | var deps = new DependencyContainer(base.CreateChildDependencies(parent)); 34 | 35 | deps.Cache(new RomStore(LocalStorage)); 36 | deps.Cache(new GamebosuConfigManager(parent.Get(), new GamebosuRuleset().RulesetInfo)); 37 | 38 | return deps; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/TestSceneClockRateIndicator.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Bindables; 5 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Gameplay; 6 | using osu.Game.Tests.Visual; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.Tests 9 | { 10 | public partial class TestSceneClockRateIndicator : OsuTestScene 11 | { 12 | private readonly ClockRateIndicator indic; 13 | 14 | private readonly BindableDouble val = new BindableDouble 15 | { 16 | MinValue = 0, 17 | MaxValue = 10, 18 | Value = 5, 19 | }; 20 | 21 | public TestSceneClockRateIndicator() 22 | { 23 | Child = indic = new ClockRateIndicator 24 | { 25 | Anchor = Framework.Graphics.Anchor.BottomCentre, 26 | Origin = Framework.Graphics.Anchor.BottomCentre, 27 | Margin = new Framework.Graphics.MarginPadding { Bottom = 20 } 28 | }; 29 | 30 | indic.Rate.BindTo(val); 31 | 32 | AddStep("show", () => indic.Show()); 33 | AddSliderStep("slider", 0.0, 10.0, 5.0, t => val.Value = t); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/TestSceneGameboyClock.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Framework.Graphics.Shapes; 7 | using osu.Game.Rulesets.Gamebosu.UI.Gameboy; 8 | using osu.Game.Tests.Visual; 9 | using osuTK.Graphics; 10 | 11 | namespace osu.Game.Rulesets.Gamebosu.Tests 12 | { 13 | public partial class TestSceneGameboyClock : OsuTestScene 14 | { 15 | private readonly DrawableGameboyClock clock; 16 | private readonly Box box; 17 | 18 | public TestSceneGameboyClock() 19 | { 20 | Children = new Drawable[] 21 | { 22 | clock = new DrawableGameboyClock(), 23 | box = new Box 24 | { 25 | RelativeSizeAxes = Axes.Both, 26 | Colour = Color4.White 27 | } 28 | }; 29 | 30 | AddSliderStep("clock rate", 0, 2, 1, t => 31 | { 32 | clock.Rate.Value = t; 33 | }); 34 | 35 | AddToggleStep("enable clock", t => 36 | { 37 | if (t) 38 | clock.Start(); 39 | else 40 | clock.Stop(); 41 | }); 42 | } 43 | 44 | [BackgroundDependencyLoader] 45 | private void load() 46 | { 47 | clock.Tick += (_, __) => box.FlashColour(Color4.Yellow, 100); 48 | clock.Start(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/TestSceneOsuGame.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Tests.Visual; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Tests 7 | { 8 | public partial class TestSceneOsuGame : OsuGameTestScene 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/VisualTestRunner.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. 2 | // See the LICENCE file in the repository root for full licence text. 3 | 4 | using System; 5 | using osu.Framework; 6 | using osu.Framework.Platform; 7 | using osu.Game.Tests; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.Tests 10 | { 11 | public static class VisualTestRunner 12 | { 13 | [STAThread] 14 | public static int Main(string[] args) 15 | { 16 | using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions())) 17 | { 18 | host.Run(new OsuTestBrowser()); 19 | return 0; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.Tests/osu.Game.Rulesets.Gamebosu.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | osu.Game.Rulesets.Gamebosu.Tests.VisualTestRunner 4 | 5 | 6 | 7 | 8 | 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | WinExe 23 | net8.0 24 | osu.Game.Rulesets.Gamebosu.Tests 25 | 26 | 27 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29123.88 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Gamebosu", "osu.Game.Rulesets.Gamebosu\osu.Game.Rulesets.Gamebosu.csproj", "{5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Gamebosu.Tests", "osu.Game.Rulesets.Gamebosu.Tests\osu.Game.Rulesets.Gamebosu.Tests.csproj", "{B4577C85-CB83-462A-BCE3-22FFEB16311D}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emux.GameBoy", "Emux\Emux.GameBoy\Emux.GameBoy.csproj", "{4E959EAB-324B-48B4-A4B9-9E0C567F8B47}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | VisualTests|Any CPU = VisualTests|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.Release|Any CPU.Build.0 = Release|Any CPU 23 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.VisualTests|Any CPU.ActiveCfg = Release|Any CPU 24 | {5AE1F0F1-DAFA-46E7-959C-DA233B7C87E9}.VisualTests|Any CPU.Build.0 = Release|Any CPU 25 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.VisualTests|Any CPU.ActiveCfg = Debug|Any CPU 30 | {B4577C85-CB83-462A-BCE3-22FFEB16311D}.VisualTests|Any CPU.Build.0 = Debug|Any CPU 31 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.VisualTests|Any CPU.ActiveCfg = Debug|Any CPU 36 | {4E959EAB-324B-48B4-A4B9-9E0C567F8B47}.VisualTests|Any CPU.Build.0 = Debug|Any CPU 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | SolutionGuid = {671B0BEC-2403-45B0-9357-2C97CC517668} 43 | EndGlobalSection 44 | GlobalSection(MonoDevelopProperties) = preSolution 45 | Policies = $0 46 | $0.TextStylePolicy = $1 47 | $1.EolMarker = Windows 48 | $1.inheritsSet = VisualStudio 49 | $1.inheritsScope = text/plain 50 | $1.scope = text/x-csharp 51 | $0.CSharpFormattingPolicy = $2 52 | $2.IndentSwitchSection = True 53 | $2.NewLinesForBracesInProperties = True 54 | $2.NewLinesForBracesInAccessors = True 55 | $2.NewLinesForBracesInAnonymousMethods = True 56 | $2.NewLinesForBracesInControlBlocks = True 57 | $2.NewLinesForBracesInAnonymousTypes = True 58 | $2.NewLinesForBracesInObjectCollectionArrayInitializers = True 59 | $2.NewLinesForBracesInLambdaExpressionBody = True 60 | $2.NewLineForElse = True 61 | $2.NewLineForCatch = True 62 | $2.NewLineForFinally = True 63 | $2.NewLineForMembersInObjectInit = True 64 | $2.NewLineForMembersInAnonymousTypes = True 65 | $2.NewLineForClausesInQuery = True 66 | $2.SpacingAfterMethodDeclarationName = False 67 | $2.SpaceAfterMethodCallName = False 68 | $2.SpaceBeforeOpenSquareBracket = False 69 | $2.inheritsSet = Mono 70 | $2.inheritsScope = text/x-csharp 71 | $2.scope = text/x-csharp 72 | EndGlobalSection 73 | GlobalSection(MonoDevelopProperties) = preSolution 74 | Policies = $0 75 | $0.TextStylePolicy = $1 76 | $1.EolMarker = Windows 77 | $1.inheritsSet = VisualStudio 78 | $1.inheritsScope = text/plain 79 | $1.scope = text/x-csharp 80 | $0.CSharpFormattingPolicy = $2 81 | $2.IndentSwitchSection = True 82 | $2.NewLinesForBracesInProperties = True 83 | $2.NewLinesForBracesInAccessors = True 84 | $2.NewLinesForBracesInAnonymousMethods = True 85 | $2.NewLinesForBracesInControlBlocks = True 86 | $2.NewLinesForBracesInAnonymousTypes = True 87 | $2.NewLinesForBracesInObjectCollectionArrayInitializers = True 88 | $2.NewLinesForBracesInLambdaExpressionBody = True 89 | $2.NewLineForElse = True 90 | $2.NewLineForCatch = True 91 | $2.NewLineForFinally = True 92 | $2.NewLineForMembersInObjectInit = True 93 | $2.NewLineForMembersInAnonymousTypes = True 94 | $2.NewLineForClausesInQuery = True 95 | $2.SpacingAfterMethodDeclarationName = False 96 | $2.SpaceAfterMethodCallName = False 97 | $2.SpaceBeforeOpenSquareBracket = False 98 | $2.inheritsSet = Mono 99 | $2.inheritsScope = text/x-csharp 100 | $2.scope = text/x-csharp 101 | EndGlobalSection 102 | EndGlobal 103 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu.sln.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cs 2 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 3 | // See LICENSE at root of repo for more information on licensing. 4 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Audio/BASSAudioChannelOutput.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy.Audio; 5 | using ManagedBass; 6 | using osu.Framework.Audio; 7 | using osu.Framework.Bindables; 8 | using System; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace osu.Game.Rulesets.Gamebosu.Audio 12 | { 13 | //TODO: Fix audio weird noises. 14 | public class BassAudioChannelOutput : AdjustableAudioComponent, IAudioChannelOutput, IDisposable 15 | { 16 | private int bassChannel; 17 | 18 | public int SampleRate => 44100; 19 | 20 | private CircularBuffer buff; 21 | 22 | private readonly BindableDouble adjustmentBindable = new BindableDouble(0.08); 23 | 24 | public BassAudioChannelOutput() 25 | { 26 | bassChannel = Bass.CreateStream(SampleRate, 2, BassFlags.Default | BassFlags.Float, fetchBassData); 27 | buff = new CircularBuffer(64768); 28 | 29 | AddAdjustment(AdjustableProperty.Volume, adjustmentBindable); 30 | AggregateVolume.BindValueChanged(t => Bass.ChannelSetAttribute(bassChannel, ChannelAttribute.Volume, t.NewValue), true); 31 | } 32 | 33 | public bool Play() => Bass.ChannelPlay(bassChannel); 34 | 35 | public bool Stop() => Bass.ChannelStop(bassChannel); 36 | 37 | public void BufferSoundSamples(Span sampleData, int offset, int length) => buff.Enqueue(sampleData); 38 | 39 | private int fetchBassData(int handle, IntPtr buffer, int bufferLength, IntPtr user) 40 | { 41 | var length = bufferLength / sizeof(float); 42 | var sData = new float[length]; 43 | 44 | buff.Dequeue(sData.AsSpan()); 45 | Marshal.Copy(sData, 0, buffer, length); 46 | 47 | return bufferLength; 48 | } 49 | 50 | protected override void Dispose(bool disposing) 51 | { 52 | Stop(); 53 | Bass.StreamFree(bassChannel); 54 | 55 | base.Dispose(disposing); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Audio/CircularBuffer.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using System; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Audio 7 | { 8 | /// 9 | /// A Span version of a fixed-size buffer, that should eventually become actually "circular". 10 | /// 11 | public class CircularBuffer 12 | where T : struct 13 | { 14 | private Memory mem; 15 | 16 | public CircularBuffer(int workingSize) 17 | { 18 | mem = new Memory(new T[workingSize]); 19 | } 20 | 21 | public void Enqueue(Span data) 22 | { 23 | if (data.Length > mem.Span.Length) 24 | data.Slice(mem.Span.Length).CopyTo(mem.Span); 25 | else 26 | data.CopyTo(mem.Span); 27 | } 28 | 29 | public void Dequeue(Span outdata) 30 | { 31 | if (mem.Span.Length > outdata.Length) 32 | mem.Span.Slice(0, outdata.Length).CopyTo(outdata); 33 | else 34 | mem.Span.CopyTo(outdata); 35 | 36 | mem.Span.Fill(default(T)); //clears the buffer 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Beatmaps/GamebosuBeatmapConverter.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Beatmaps; 5 | using osu.Game.Rulesets.Gamebosu.Objects; 6 | using osu.Game.Rulesets.Objects; 7 | using System.Collections.Generic; 8 | using System.Threading; 9 | 10 | namespace osu.Game.Rulesets.Gamebosu.Beatmaps 11 | { 12 | public class GamebosuBeatmapConverter : BeatmapConverter 13 | { 14 | public GamebosuBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) 15 | : base(beatmap, ruleset) 16 | { 17 | } 18 | 19 | public override bool CanConvert() => true; 20 | 21 | protected override IEnumerable ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken) 22 | { 23 | yield return new GamebosuHitObject 24 | { 25 | Samples = original.Samples, 26 | StartTime = original.StartTime, 27 | }; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Configuration/GamebosuConfigManager.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Configuration; 5 | using osu.Game.Rulesets.Configuration; 6 | 7 | namespace osu.Game.Rulesets.Gamebosu.Configuration 8 | { 9 | public class GamebosuConfigManager : RulesetConfigManager 10 | { 11 | public GamebosuConfigManager(SettingsStore settings, RulesetInfo ruleset) 12 | : base(settings, ruleset, 0) 13 | { 14 | } 15 | 16 | protected override void InitialiseDefaults() 17 | { 18 | SetDefault(GamebosuSetting.LockClockRate, false); 19 | SetDefault(GamebosuSetting.ClockRate, 1, 0.1, 5, 0.1); 20 | SetDefault(GamebosuSetting.PreferGBCMode, true); 21 | SetDefault(GamebosuSetting.GameboyScale, 2f, 1f, 4.5f, 0.1f); 22 | SetDefault(GamebosuSetting.EnableSoundPlayback, false); //Disable the audio playback by default since it is very experimental. 23 | SetDefault(GamebosuSetting.DisableDisplayingThatAnnoyingDisclaimer, false); 24 | base.InitialiseDefaults(); 25 | } 26 | } 27 | 28 | public enum GamebosuSetting 29 | { 30 | LockClockRate, 31 | ClockRate, 32 | GameboyScale, 33 | PreferGBCMode, 34 | EnableSoundPlayback, 35 | DisableDisplayingThatAnnoyingDisclaimer, 36 | } 37 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | true 4 | Emux.GameBoy 5 | 6 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/GamebosuDifficultyCalculator.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Beatmaps; 5 | using osu.Game.Rulesets.Difficulty; 6 | using osu.Game.Rulesets.Difficulty.Preprocessing; 7 | using osu.Game.Rulesets.Difficulty.Skills; 8 | using osu.Game.Rulesets.Mods; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu 14 | { 15 | public class GamebosuDifficultyCalculator : DifficultyCalculator 16 | { 17 | public GamebosuDifficultyCalculator(Ruleset ruleset, IWorkingBeatmap beatmap) 18 | : base(ruleset.RulesetInfo, beatmap) 19 | { 20 | } 21 | 22 | protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) 23 | => new DifficultyAttributes(mods, 0); 24 | 25 | protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) => Enumerable.Empty(); 26 | 27 | protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate) => Array.Empty(); 28 | } 29 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/GamebosuRuleset.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Input.Bindings; 6 | using osu.Game.Beatmaps; 7 | using osu.Game.Configuration; 8 | using osu.Game.Overlays.Settings; 9 | using osu.Game.Rulesets.Configuration; 10 | using osu.Game.Rulesets.Difficulty; 11 | using osu.Game.Rulesets.Gamebosu.Beatmaps; 12 | using osu.Game.Rulesets.Gamebosu.Configuration; 13 | using osu.Game.Rulesets.Gamebosu.Graphics; 14 | using osu.Game.Rulesets.Gamebosu.UI; 15 | using osu.Game.Rulesets.Gamebosu.UI.Configuration; 16 | using osu.Game.Rulesets.Gamebosu.UI.Input; 17 | using osu.Game.Rulesets.Mods; 18 | using osu.Game.Rulesets.Scoring; 19 | using osu.Game.Rulesets.UI; 20 | using System; 21 | using System.Collections.Generic; 22 | 23 | namespace osu.Game.Rulesets.Gamebosu 24 | { 25 | public class GamebosuRuleset : Ruleset 26 | { 27 | public override string Description => "gamebosu!"; 28 | 29 | public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => 30 | new DrawableGamebosuRuleset(this, beatmap, mods); 31 | 32 | public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => 33 | new GamebosuBeatmapConverter(beatmap, this); 34 | 35 | public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => 36 | new GamebosuDifficultyCalculator(this, beatmap); 37 | 38 | //this exists for the sole purpose of disabling the red tint on playfield when health is low. 39 | public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new AccumulatingHealthProcessor(1f); 40 | 41 | public override IEnumerable GetModsFor(ModType type) => Array.Empty(); 42 | 43 | public override string ShortName => "gamebosu"; 44 | 45 | public override string PlayingVerb => $"Playing gameboy"; 46 | 47 | public override IEnumerable GetDefaultKeyBindings(int variant = 0) => new[] 48 | { 49 | new KeyBinding(InputKey.Left, GamebosuAction.DPadLeft), 50 | new KeyBinding(InputKey.Right, GamebosuAction.DPadRight), 51 | new KeyBinding(InputKey.Up, GamebosuAction.DPadUp), 52 | new KeyBinding(InputKey.Down, GamebosuAction.DPadDown), 53 | 54 | new KeyBinding(InputKey.PageUp, GamebosuAction.ButtonIncrementClockRate), 55 | new KeyBinding(InputKey.PageDown, GamebosuAction.ButtonDecrementClockRate), 56 | 57 | new KeyBinding(InputKey.A, GamebosuAction.ButtonA), 58 | new KeyBinding(InputKey.B, GamebosuAction.ButtonB), 59 | new KeyBinding(InputKey.Enter, GamebosuAction.ButtonSelect), 60 | new KeyBinding(InputKey.BackSpace, GamebosuAction.ButtonStart), 61 | }; 62 | 63 | public override Drawable CreateIcon() => new RulesetIcon(this) 64 | { 65 | Anchor = Anchor.Centre, 66 | Origin = Anchor.Centre, 67 | }; 68 | 69 | public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new GamebosuConfigManager(settings, RulesetInfo); 70 | 71 | public override RulesetSettingsSubsection CreateSettings() => new GamebosuSettingsSubsection(this); 72 | } 73 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Graphics/GamebosuToolbarIcon.cs: -------------------------------------------------------------------------------- 1 | using osu.Framework.Allocation; 2 | using osu.Framework.Graphics.Sprites; 3 | using osu.Framework.Graphics.Textures; 4 | using osu.Framework.Screens; 5 | using osu.Game.Overlays.Toolbar; 6 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 7 | using osu.Game.Screens.Play; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.Graphics 10 | { 11 | public partial class GamebosuToolbarIcon : ToolbarButton 12 | { 13 | private readonly GamebosuRuleset ruleset; 14 | 15 | public GamebosuToolbarIcon(GamebosuRuleset ruleset) 16 | { 17 | this.ruleset = ruleset; 18 | TooltipMain = "gamebosu"; 19 | TooltipSub = "Open the ROM selection screen"; 20 | } 21 | 22 | [BackgroundDependencyLoader] 23 | private void load(OsuGame game, ILocalUserPlayInfo playing, TextureStore textures) 24 | { 25 | SetIcon(new Sprite 26 | { 27 | Texture = textures.Get("Textures/gamebosu_toolbar.png") 28 | }); 29 | 30 | Action = () => 31 | { 32 | 33 | if (playing.PlayingState.Value == LocalUserPlayingState.NotPlaying) 34 | game.PerformFromScreen(scr => scr.Push(new GamebosuMainScreen(ruleset))); 35 | }; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Graphics/RulesetIcon.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Framework.Graphics.Containers; 7 | using osu.Framework.Graphics.Sprites; 8 | using osu.Framework.Graphics.Textures; 9 | using osu.Game.Rulesets.Gamebosu.Utils; 10 | using osuTK; 11 | using osuTK.Graphics; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu.Graphics 14 | { 15 | public partial class RulesetIcon : CompositeDrawable 16 | { 17 | protected override bool CanBeFlattened => true; 18 | 19 | private readonly GamebosuRuleset ruleset; 20 | 21 | public RulesetIcon(GamebosuRuleset ruleset) 22 | { 23 | this.ruleset = ruleset; 24 | } 25 | 26 | [BackgroundDependencyLoader] 27 | private void load(OsuGame game, TextureStore store) 28 | { 29 | // startup tasks are run from here as the ruleset icon is the first long-lived component initialized 30 | // by the game UI that has access to DI. 31 | StartupTaskQueue.RunStartupTasks(game, ruleset); 32 | 33 | AutoSizeAxes = Axes.Both; 34 | InternalChildren = new Drawable[] 35 | { 36 | new SpriteIcon 37 | { 38 | Anchor = Anchor.Centre, 39 | Origin = Anchor.Centre, 40 | Icon = FontAwesome.Regular.Circle, 41 | Size = new Vector2(60), 42 | Colour = Color4.White 43 | }, 44 | new Sprite 45 | { 46 | Anchor = Anchor.Centre, 47 | Origin = Anchor.Centre, 48 | Texture = store.Get("Textures/logo_pixelated.png"), 49 | FillMode = FillMode.Fit, 50 | Size = new Vector2(40) 51 | } 52 | }; 53 | } 54 | 55 | protected override void Dispose(bool isDisposing) 56 | { 57 | StartupTaskQueue.FreeInstance(); 58 | base.Dispose(isDisposing); 59 | } 60 | 61 | //todo: move this to a more appropriate place ?. 62 | [StartupTask(Priority = int.MinValue)] 63 | private static void registerResources(OsuGame game, GamebosuRuleset ruleset) { 64 | game.Textures.AddTextureSource(new TextureLoaderStore(ruleset.CreateResourceStore())); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Graphics/ScrollingSpriteText.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Graphics.Transforms; 6 | using osu.Game.Graphics.Sprites; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.Graphics 9 | { 10 | /// 11 | /// A that scrolls if its width is bigger than its parent. 12 | /// 13 | public partial class ScrollingSpriteText : OsuSpriteText 14 | { 15 | private TransformSequence scrollTransformSequence; 16 | 17 | private const double transform_time = 250; 18 | 19 | protected override void Update() 20 | { 21 | //if the width goes off of its parent width, let's just make it slide from left to right 22 | if (DrawWidth > Parent?.Width && scrollTransformSequence == null) 23 | { 24 | Anchor = Anchor.CentreLeft; 25 | Origin = Anchor.CentreLeft; 26 | 27 | var speedRatio = DrawWidth / Parent.DrawWidth * 8; 28 | 29 | scrollTransformSequence = this.MoveToX(-(DrawWidth + 20), speedRatio * DrawWidth) 30 | .Then() 31 | .FadeOut(transform_time) 32 | .Then() 33 | .MoveToX(0) 34 | .Delay(transform_time) 35 | .FadeIn(transform_time) 36 | .Loop(); 37 | } 38 | 39 | base.Update(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/IO/RomStore.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy.Cartridge; 5 | using osu.Framework.IO.Stores; 6 | using osu.Framework.Logging; 7 | using osu.Framework.Platform; 8 | using System.Collections.Generic; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Threading; 12 | using System.Threading.Tasks; 13 | 14 | namespace osu.Game.Rulesets.Gamebosu.IO 15 | { 16 | public class RomStore : ResourceStore 17 | { 18 | /// 19 | /// The rom storage. 20 | /// 21 | public Storage Storage { get; } 22 | 23 | private readonly Storage savesStorage; 24 | 25 | public static IEnumerable RecognizedExtensions = new[] 26 | { 27 | ".gbc", 28 | ".gb", 29 | ".GB", 30 | ".GBC" 31 | }; 32 | 33 | private const string save_file_extension = ".sav"; 34 | 35 | public RomStore(Storage storage) 36 | { 37 | Storage = storage.GetStorageForDirectory("roms"); 38 | savesStorage = this.Storage.GetStorageForDirectory("saves"); 39 | 40 | foreach (var ext in RecognizedExtensions) 41 | AddExtension(ext); 42 | } 43 | 44 | public override EmulatedCartridge Get(string name) 45 | { 46 | foreach (var resName in GetFilenames(name)) 47 | { 48 | try 49 | { 50 | if (Storage.Exists(resName)) 51 | { 52 | var cartStream = Storage.GetStream(resName); 53 | var cartRom = new byte[cartStream.Length]; 54 | cartStream.Read(cartRom, 0, (int)cartStream.Length); 55 | 56 | var saveStream = savesStorage.GetStream(resName + save_file_extension, FileAccess.ReadWrite, FileMode.OpenOrCreate); 57 | return new EmulatedCartridge(cartRom, new StreamedExternalMemory(saveStream)); 58 | } 59 | } 60 | catch (System.Exception e) 61 | { 62 | Logger.Log("Load of cartridge failed: " + e.ToString(), LoggingTarget.Runtime); 63 | continue; 64 | } 65 | } 66 | 67 | return null; 68 | } 69 | 70 | public override Task GetAsync(string name, CancellationToken token = default) => Task.Run(() => Get(name), token); 71 | 72 | public override IEnumerable GetAvailableResources() => Storage.GetFiles(".") 73 | .ExcludeSystemFileNames() 74 | .Where(file => RecognizedExtensions.Any(ext => Path.GetExtension(file)?.Equals(ext, System.StringComparison.Ordinal) ?? false)); 75 | } 76 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Objects/Drawables/DrawableGamebosuHitObject.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Game.Rulesets.Objects.Drawables; 6 | using osuTK; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.Objects.Drawables 9 | { 10 | public partial class DrawableGamebosuHitObject : DrawableHitObject 11 | { 12 | public DrawableGamebosuHitObject(GamebosuHitObject hitObject) 13 | : base(hitObject) 14 | { 15 | Size = Vector2.Zero; 16 | Origin = Anchor.Centre; 17 | } 18 | 19 | protected override void CheckForResult(bool userTriggered, double timeOffset) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Objects/GamebosuHitObject.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Rulesets.Judgements; 5 | using osu.Game.Rulesets.Objects; 6 | 7 | namespace osu.Game.Rulesets.Gamebosu.Objects 8 | { 9 | public class GamebosuHitObject : HitObject 10 | { 11 | public override Judgement CreateJudgement() => new Judgement(); 12 | } 13 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Replays/GamebosuFramedReplayInputHandler.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Input.StateChanges; 5 | using osu.Game.Replays; 6 | using osu.Game.Rulesets.Replays; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | 10 | namespace osu.Game.Rulesets.Gamebosu.Replays 11 | { 12 | public class GamebosuFramedReplayInputHandler : FramedReplayInputHandler 13 | { 14 | public GamebosuFramedReplayInputHandler(Replay replay) 15 | : base(replay) 16 | { 17 | } 18 | 19 | protected override bool IsImportant(GamebosuReplayFrame frame) => frame.Actions.Any(); 20 | 21 | protected override void CollectReplayInputs(List inputs) 22 | { 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Replays/GamebosuReplayFrame.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Rulesets.Gamebosu.UI.Input; 5 | using osu.Game.Rulesets.Replays; 6 | using System.Collections.Generic; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.Replays 9 | { 10 | public class GamebosuReplayFrame : ReplayFrame 11 | { 12 | public List Actions = new List(); 13 | 14 | public GamebosuReplayFrame(GamebosuAction? button = null) 15 | { 16 | if (button.HasValue) 17 | Actions.Add(button.Value); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/cartridge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/cartridge.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/dmg_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/dmg_sprite.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/emu_crash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/emu_crash.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/emu_went_brrr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/emu_went_brrr.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/gamebosu_toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/gamebosu_toolbar.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/logo.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Resources/Textures/logo_pixelated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Game4all/gamebosu/6b9b03d8dcde9ff4f9feb3686025e99bc97bf49b/osu.Game.Rulesets.Gamebosu/Resources/Textures/logo_pixelated.png -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Configuration/DeleteDataDialog.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics.Sprites; 5 | using osu.Game.Overlays.Dialog; 6 | using System; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.UI.Configuration 9 | { 10 | public partial class DeleteDataDialog : PopupDialog 11 | { 12 | public DeleteDataDialog(Action action) 13 | { 14 | HeaderText = "Delete ROM save data?"; 15 | BodyText = "Your precious ROM save files will be returned to void. Are you sure?"; 16 | 17 | Icon = FontAwesome.Regular.TrashAlt; 18 | Buttons = new PopupDialogButton[] 19 | { 20 | new PopupDialogOkButton 21 | { 22 | Text = @"Yes. I'll start from zero again.", 23 | Action = action 24 | }, 25 | new PopupDialogCancelButton 26 | { 27 | Text = @"No! Abort mission!", 28 | }, 29 | }; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Configuration/DeleteDataErrorDialog.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics.Sprites; 5 | using osu.Game.Overlays.Dialog; 6 | 7 | namespace osu.Game.Rulesets.Gamebosu.UI.Configuration 8 | { 9 | public partial class DeleteDataErrorDialog : PopupDialog 10 | { 11 | public DeleteDataErrorDialog() 12 | { 13 | HeaderText = "An error occured while trying to delete ROM save data..."; 14 | Icon = FontAwesome.Solid.Exclamation; 15 | 16 | Buttons = new PopupDialogButton[] 17 | { 18 | new PopupDialogOkButton 19 | { 20 | Text = @"Ok", 21 | }, 22 | }; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Configuration/GamebosuSettingsSubsection.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Bindables; 6 | using osu.Framework.Extensions.IEnumerableExtensions; 7 | using osu.Framework.Graphics; 8 | using osu.Framework.Localisation; 9 | using osu.Framework.Platform; 10 | using osu.Framework.Screens; 11 | using osu.Game.Graphics; 12 | using osu.Game.Overlays; 13 | using osu.Game.Overlays.Settings; 14 | using osu.Game.Rulesets.Gamebosu.Configuration; 15 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 16 | using System; 17 | 18 | namespace osu.Game.Rulesets.Gamebosu.UI.Configuration 19 | { 20 | public partial class GamebosuSettingsSubsection : RulesetSettingsSubsection 21 | { 22 | private SettingsSlider clockRate; 23 | private Bindable lockClockRate; 24 | 25 | private readonly GamebosuRuleset ruleset; 26 | 27 | public GamebosuSettingsSubsection(GamebosuRuleset ruleset) 28 | : base(ruleset) 29 | { 30 | this.ruleset = ruleset; 31 | } 32 | 33 | protected override LocalisableString Header => "gamebosu!"; 34 | 35 | [BackgroundDependencyLoader] 36 | private void load(Storage storage, IDialogOverlay dialog, OsuGame game) 37 | { 38 | var config = Config as GamebosuConfigManager; 39 | lockClockRate = config.GetBindable(GamebosuSetting.LockClockRate); 40 | 41 | Children = new Drawable[] 42 | { 43 | clockRate = new SettingsSlider 44 | { 45 | LabelText = "Gameboy Clock rate", 46 | Current = config.GetBindable(GamebosuSetting.ClockRate) 47 | }, 48 | new SettingsCheckbox 49 | { 50 | LabelText = "Lock gameboy clock rate", 51 | Current = lockClockRate 52 | }, 53 | new SettingsCheckbox 54 | { 55 | LabelText = "Prefer Gameboy Color mode when launching original gameboy ROMs", 56 | Current = config.GetBindable(GamebosuSetting.PreferGBCMode) 57 | }, 58 | new SettingsSlider 59 | { 60 | LabelText = "Gameboy Scale", 61 | Current = config.GetBindable(GamebosuSetting.GameboyScale) 62 | }, 63 | new SettingsButton 64 | { 65 | Text = "Open ROMs folder", 66 | Action = () => storage.GetStorageForDirectory("roms")?.PresentExternally() 67 | }, 68 | new DangerousSettingsButton 69 | { 70 | Text = "Delete ROM save data", 71 | Action = () => 72 | { 73 | Action deleteAction = delegate 74 | { 75 | var saves = storage.GetStorageForDirectory("roms/saves"); 76 | var files = saves.GetFiles("."); 77 | try 78 | { 79 | files.ForEach(file => saves.Delete(file)); 80 | } 81 | catch (Exception) 82 | { 83 | dialog.Push(new DeleteDataErrorDialog 84 | { 85 | BodyText = $"Couldn't delete ROM save data (save data may be used by the currently loaded ROM). Try deleting save data from the main menu" 86 | }); 87 | } 88 | }; 89 | 90 | dialog.Push(new DeleteDataDialog(deleteAction)); 91 | } 92 | }, 93 | new SettingsCheckbox 94 | { 95 | LabelText = "Enable Sound Playback (VERY EXPERIMENTAL)", 96 | Current = config.GetBindable(GamebosuSetting.EnableSoundPlayback) 97 | }, 98 | new SettingsCheckbox 99 | { 100 | LabelText = "Disable that annoying disclaimer when launching gamebosu!", 101 | Current = config.GetBindable(GamebosuSetting.DisableDisplayingThatAnnoyingDisclaimer) 102 | }, 103 | new YellowSettingsButton 104 | { 105 | Text = "Open ROM listing", 106 | Action = () => game?.PerformFromScreen(scr => scr.Push(new GamebosuMainScreen(ruleset))) 107 | }, 108 | }; 109 | 110 | lockClockRate.BindValueChanged(e => clockRate.Current.Disabled = e.NewValue, true); 111 | } 112 | 113 | private partial class YellowSettingsButton : SettingsButton 114 | { 115 | [BackgroundDependencyLoader] 116 | private void load(OsuColour colours) 117 | { 118 | Height = 60; 119 | BackgroundColour = colours.Yellow; 120 | } 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/DrawableGamebosuRuleset.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Input; 6 | using osu.Game.Beatmaps; 7 | using osu.Game.Input.Handlers; 8 | using osu.Game.Replays; 9 | using osu.Game.Rulesets.Gamebosu.Objects; 10 | using osu.Game.Rulesets.Gamebosu.Objects.Drawables; 11 | using osu.Game.Rulesets.Gamebosu.Replays; 12 | using osu.Game.Rulesets.Mods; 13 | using osu.Game.Rulesets.Objects.Drawables; 14 | using osu.Game.Rulesets.UI; 15 | using System.Collections.Generic; 16 | 17 | namespace osu.Game.Rulesets.Gamebosu.UI 18 | { 19 | [Cached] 20 | public partial class DrawableGamebosuRuleset : DrawableRuleset 21 | { 22 | public DrawableGamebosuRuleset(GamebosuRuleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) 23 | : base(ruleset, beatmap, mods) 24 | { 25 | //should permit opening overlays while playing. 26 | HasReplayLoaded.Value = true; 27 | } 28 | 29 | protected override Playfield CreatePlayfield() => new GamebosuPlayfield(); 30 | 31 | protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new GamebosuFramedReplayInputHandler(replay); 32 | 33 | public override DrawableHitObject CreateDrawableRepresentation(GamebosuHitObject h) => new DrawableGamebosuHitObject(h); 34 | 35 | protected override PassThroughInputManager CreateInputManager() => new PassThroughInputManager(); 36 | 37 | public override bool AllowGameplayOverlays => false; 38 | } 39 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/GamebosuPlayfield.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Game.Rulesets.Gamebosu.UI.Screens; 7 | using osu.Game.Rulesets.UI; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.UI 10 | { 11 | [Cached] 12 | public partial class GamebosuPlayfield : Playfield 13 | { 14 | [BackgroundDependencyLoader] 15 | private void load() 16 | { 17 | AddRangeInternal(new Drawable[] 18 | { 19 | HitObjectContainer, 20 | new MovingNotice 21 | { 22 | Anchor = Anchor.Centre, 23 | Origin = Anchor.Centre, 24 | Size = new osuTK.Vector2(512, 256) 25 | } 26 | }); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Gameboy/CrashScreenCover.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Framework.Graphics.Sprites; 7 | using osu.Framework.Graphics.Textures; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.UI.Gameboy 10 | { 11 | public partial class CrashScreenCover : Sprite 12 | { 13 | private readonly float scale = 0.8f; 14 | 15 | public CrashScreenCover() 16 | { 17 | RelativeSizeAxes = Axes.Both; 18 | Scale = new osuTK.Vector2(scale); 19 | Anchor = Anchor.Centre; 20 | Origin = Anchor.Centre; 21 | } 22 | 23 | [BackgroundDependencyLoader] 24 | private void load(TextureStore textures) 25 | { 26 | Texture = textures.Get("Textures/emu_went_brrr"); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Gameboy/DrawableGameboy.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy; 5 | using Emux.GameBoy.Cartridge; 6 | using Emux.GameBoy.Input; 7 | using osu.Framework.Allocation; 8 | using osu.Framework.Audio; 9 | using osu.Framework.Bindables; 10 | using osu.Framework.Extensions.IEnumerableExtensions; 11 | using osu.Framework.Graphics; 12 | using osu.Framework.Graphics.Containers; 13 | using osu.Framework.Graphics.Sprites; 14 | using osu.Framework.Graphics.Textures; 15 | using osu.Framework.Input.Bindings; 16 | using osu.Framework.Input.Events; 17 | using osu.Framework.Logging; 18 | using osu.Game.Rulesets.Gamebosu.Audio; 19 | using osu.Game.Rulesets.Gamebosu.Configuration; 20 | using osu.Game.Rulesets.Gamebosu.UI.Input; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | 24 | namespace osu.Game.Rulesets.Gamebosu.UI.Gameboy 25 | { 26 | public partial class DrawableGameboy : CompositeDrawable, IKeyBindingHandler 27 | { 28 | private readonly ICartridge cartridge; 29 | 30 | private readonly DrawableGameboyClock clock; 31 | 32 | private readonly DrawableGameboyScreen screen; 33 | 34 | private readonly CrashScreenCover crashScreenCover; 35 | 36 | private readonly Sprite cutoutSprite; 37 | 38 | private GameBoy gameBoy; 39 | 40 | private IEnumerable audioChannels; 41 | 42 | private Bindable clockRate; 43 | 44 | private Bindable soundPlayback; 45 | 46 | public DrawableGameboy(ICartridge cart) 47 | { 48 | AutoSizeAxes = Axes.Both; 49 | Masking = true; 50 | CornerRadius = 5; 51 | 52 | cartridge = cart; 53 | 54 | InternalChildren = new Drawable[] 55 | { 56 | clock = new DrawableGameboyClock(), 57 | cutoutSprite = new Sprite 58 | { 59 | Anchor = Anchor.Centre, 60 | Origin = Anchor.Centre, 61 | Scale = new osuTK.Vector2(0.5f), 62 | }, 63 | new Container 64 | { 65 | Padding = new MarginPadding { Left = 2 }, 66 | Anchor = Anchor.Centre, 67 | Origin = Anchor.Centre, 68 | AutoSizeAxes = Axes.Both, 69 | Children = new Drawable[] 70 | { 71 | screen = new DrawableGameboyScreen 72 | { 73 | Size = new osuTK.Vector2(160, 144), 74 | Margin = new MarginPadding() 75 | { 76 | Top = 20 77 | }, 78 | Anchor = Anchor.Centre, 79 | Origin = Anchor.Centre 80 | }, 81 | crashScreenCover = new CrashScreenCover 82 | { 83 | Alpha = 0 84 | } 85 | } 86 | }, 87 | }; 88 | } 89 | 90 | public bool OnPressed(KeyBindingPressEvent action) 91 | { 92 | if (gameBoy == null) return false; 93 | 94 | gameBoy.KeyPad.PressedButtons |= getFromAction(action.Action); 95 | 96 | return true; 97 | } 98 | 99 | public void OnReleased(KeyBindingReleaseEvent action) 100 | { 101 | if (gameBoy == null) return; 102 | 103 | gameBoy.KeyPad.PressedButtons &= ~getFromAction(action.Action); 104 | } 105 | 106 | public void Start() 107 | { 108 | screen.Clear(); 109 | 110 | if (!gameBoy.Cpu.Running) 111 | gameBoy.Run(); 112 | } 113 | 114 | private GameBoyPadButton getFromAction(GamebosuAction action) => action switch 115 | { 116 | GamebosuAction.ButtonA => GameBoyPadButton.A, 117 | GamebosuAction.ButtonB => GameBoyPadButton.B, 118 | GamebosuAction.DPadUp => GameBoyPadButton.Up, 119 | GamebosuAction.DPadDown => GameBoyPadButton.Down, 120 | GamebosuAction.DPadRight => GameBoyPadButton.Right, 121 | GamebosuAction.DPadLeft => GameBoyPadButton.Left, 122 | GamebosuAction.ButtonStart => GameBoyPadButton.Start, 123 | GamebosuAction.ButtonSelect => GameBoyPadButton.Select, 124 | _ => 0 125 | }; 126 | 127 | [BackgroundDependencyLoader] 128 | private void load(GamebosuConfigManager cfg, AudioManager mng, TextureStore textures) 129 | { 130 | var forceGbcMode = cartridge.GameBoyColorFlag == GameBoyColorFlag.GameBoyColorOnly ? true : cfg.Get(GamebosuSetting.PreferGBCMode); 131 | 132 | gameBoy = new GameBoy(cartridge, clock, forceGbcMode); 133 | gameBoy.Gpu.VideoOutput = screen; 134 | 135 | gameBoy.Terminated += (_, e) => 136 | { 137 | if (e.Crashed) 138 | { 139 | Schedule(() => 140 | { 141 | screen.Clear(); 142 | crashScreenCover.FadeIn(300, Easing.OutQuint); 143 | }); 144 | Logger.Log($"Emulation crashed with exception: {e.Exception}", LoggingTarget.Runtime); 145 | } 146 | }; 147 | 148 | var tex = textures.Get("Textures/dmg_sprite.png"); 149 | cutoutSprite.Texture = tex; 150 | cutoutSprite.Margin = new MarginPadding 151 | { 152 | Top = tex.DisplayHeight / 2, 153 | }; 154 | 155 | foreach (var channel in gameBoy.Spu.Channels) 156 | { 157 | var bchannel = new BassAudioChannelOutput(); 158 | channel.ChannelOutput = bchannel; 159 | mng.AddItem(bchannel); 160 | } 161 | 162 | audioChannels = gameBoy.Spu.Channels.Select(t => t.ChannelOutput).OfType(); 163 | 164 | clockRate = cfg.GetBindable(GamebosuSetting.ClockRate); 165 | clock.Rate.BindTo(clockRate); 166 | 167 | soundPlayback = cfg.GetBindable(GamebosuSetting.EnableSoundPlayback); 168 | soundPlayback.BindValueChanged(t => 169 | { 170 | if (t.NewValue) 171 | audioChannels.ForEach(ch => ch.Play()); 172 | else 173 | audioChannels.ForEach(ch => ch.Stop()); 174 | }, true); 175 | } 176 | 177 | protected override void Dispose(bool isDisposing) 178 | { 179 | gameBoy?.Dispose(); 180 | 181 | foreach (var channel in audioChannels) 182 | channel.Dispose(); 183 | 184 | base.Dispose(isDisposing); 185 | } 186 | } 187 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Gameboy/DrawableGameboyClock.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy.Cpu; 5 | using osu.Framework.Bindables; 6 | using osu.Framework.Graphics; 7 | using System; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.UI.Gameboy 10 | { 11 | /// 12 | /// A gameboy CPU wrapped into a to access for timing purposes. 13 | /// 14 | public partial class DrawableGameboyClock : Component, IClock 15 | { 16 | private double lastTickTime; 17 | 18 | private const int clock_rate = 60; 19 | 20 | public event EventHandler Tick; 21 | 22 | public bool IsActive { get; private set; } 23 | 24 | public void Start() => IsActive = true; 25 | 26 | public void Stop() => IsActive = false; 27 | 28 | public readonly BindableDouble Rate = new BindableDouble(1) 29 | { 30 | MinValue = 0.01, 31 | MaxValue = 5 32 | }; 33 | 34 | protected override void Update() 35 | { 36 | if (!IsActive) return; 37 | 38 | var timeDelta = Time.Current - lastTickTime; 39 | 40 | if (timeDelta > 1000 / (clock_rate * Rate.Value)) 41 | { 42 | Tick?.Invoke(null, EventArgs.Empty); 43 | lastTickTime = Time.Current; 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Gameboy/DrawableGameboyScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy.Graphics; 5 | using osu.Framework.Graphics.Sprites; 6 | using osu.Framework.Graphics.Textures; 7 | using System; 8 | using osu.Framework.Allocation; 9 | using osu.Framework.Platform; 10 | using osuTK.Graphics; 11 | 12 | namespace osu.Game.Rulesets.Gamebosu.UI.Gameboy 13 | { 14 | /// 15 | /// The drawable screen of a gameboy emulator. 16 | /// 17 | public partial class DrawableGameboyScreen : Sprite, IVideoOutput 18 | { 19 | private readonly SpanTextureUpload upload; 20 | private Memory screenData; 21 | 22 | [BackgroundDependencyLoader] 23 | private void load(GameHost host) 24 | { 25 | Texture = host.Renderer.CreateTexture(160, 144, false, TextureFilteringMode.Nearest, WrapMode.ClampToEdge, WrapMode.ClampToEdge, Color4.White); 26 | } 27 | 28 | public DrawableGameboyScreen() 29 | { 30 | screenData = new Memory(new byte[160 * 144 * sizeof(int)]); //since the 4 components of a color (r, g, b a) are each a byte (4 bytes in total), the same as an int. 31 | upload = new SpanTextureUpload(screenData); 32 | } 33 | 34 | public void Clear() 35 | { 36 | for (int i = 0; i < screenData.Length; i++) 37 | screenData.Span[i] = byte.MaxValue; 38 | 39 | Texture.SetData(upload); 40 | } 41 | 42 | public void RenderFrame(byte[] pixelData) 43 | { 44 | for (int i = 0, j = 0; j < pixelData.Length; i += 4, j += 3) 45 | { 46 | screenData.Span[i] = pixelData[j]; //r component 47 | screenData.Span[i + 1] = pixelData[j + 1]; //g component 48 | screenData.Span[i + 2] = pixelData[j + 2]; //b component 49 | screenData.Span[i + 3] = byte.MaxValue; // gameboy doesn't handle opacity, so let's force it to max value. 50 | } 51 | 52 | Texture.SetData(upload); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Gameboy/SpanTextureUpload.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics.Primitives; 5 | using osu.Framework.Graphics.Textures; 6 | using osuTK.Graphics.ES30; 7 | using SixLabors.ImageSharp.PixelFormats; 8 | using System; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace osu.Game.Rulesets.Gamebosu.UI.Gameboy 12 | { 13 | public class SpanTextureUpload : ITextureUpload 14 | { 15 | private readonly Memory uploadData; 16 | 17 | public SpanTextureUpload(Memory uploadData) 18 | { 19 | this.uploadData = uploadData; 20 | } 21 | 22 | public ReadOnlySpan Data => MemoryMarshal.Cast(uploadData.Span); 23 | 24 | public int Level => 0; 25 | 26 | private RectangleI bounds = new RectangleI(0, 0, 160, 144); 27 | 28 | public RectangleI Bounds 29 | { 30 | get => bounds; 31 | set => bounds = value; 32 | } 33 | 34 | public PixelFormat Format => PixelFormat.Rgba; 35 | 36 | public void Dispose() 37 | { 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Input/GamebosuAction.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace osu.Game.Rulesets.Gamebosu.UI.Input 4 | { 5 | public enum GamebosuAction 6 | { 7 | [Description("DPad Right")] 8 | DPadRight, 9 | 10 | [Description("DPad Left")] 11 | DPadLeft, 12 | 13 | [Description("DPad Up")] 14 | DPadUp, 15 | 16 | [Description("DPad Down")] 17 | DPadDown, 18 | 19 | [Description("A Button")] 20 | ButtonA, 21 | 22 | [Description("B Button")] 23 | ButtonB, 24 | 25 | [Description("Start Button")] 26 | ButtonStart, 27 | 28 | [Description("Select Button")] 29 | ButtonSelect, 30 | 31 | [Description("Increment clock rate")] 32 | ButtonIncrementClockRate, 33 | 34 | [Description("Decrement clock rate")] 35 | ButtonDecrementClockRate 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Input/GamebosuInputManager.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Graphics.Containers; 6 | using osu.Framework.Input; 7 | using osu.Framework.Input.Bindings; 8 | using osu.Game.Input.Bindings; 9 | 10 | namespace osu.Game.Rulesets.Gamebosu.UI.Input 11 | { 12 | public partial class GamebosuInputManager : PassThroughInputManager 13 | { 14 | private readonly RulesetKeyBindingContainer keybindingContainer; 15 | 16 | protected override Container Content => content; 17 | 18 | private readonly Container content; 19 | 20 | public GamebosuInputManager(RulesetInfo ruleset) 21 | { 22 | InternalChild = (keybindingContainer = new RulesetKeyBindingContainer(ruleset, 0, SimultaneousBindingMode.All).WithChild(content = new Container 23 | { 24 | RelativeSizeAxes = Axes.Both 25 | })); 26 | } 27 | 28 | private partial class RulesetKeyBindingContainer : DatabasedKeyBindingContainer 29 | { 30 | protected override bool HandleRepeats => false; 31 | 32 | public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) 33 | : base(ruleset, variant, unique, KeyCombinationMatchingMode.Any) 34 | { 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/DisclaimerSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Extensions.Color4Extensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Framework.Graphics.Shapes; 9 | using osu.Framework.Graphics.Sprites; 10 | using osu.Framework.Input.Bindings; 11 | using osu.Framework.Input.Events; 12 | using osu.Framework.Screens; 13 | using osu.Framework.Utils; 14 | using osu.Game.Graphics; 15 | using osu.Game.Graphics.Containers; 16 | using osu.Game.Rulesets.Gamebosu.UI.Input; 17 | using osuTK.Graphics; 18 | using System; 19 | 20 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 21 | { 22 | public partial class DisclaimerSubScreen : GamebosuSubScreen, IKeyBindingHandler 23 | { 24 | private readonly OsuTextFlowContainer textFlow; 25 | 26 | private static readonly string[] disclaimer_tips = 27 | { 28 | "You can delete ROM save data from the settings overlay, try searching for 'delete ROM save data'!", 29 | "Try pressing Page-up or Page-down to change the ROM emulation speed!", 30 | "You can customize the gameboy screen scale from the settings overlay, try searching for 'gameboy scale'!", 31 | "You can open the ROM folder from the settings overlay, try searching for 'open rom folder'!", 32 | "You can enable audio playback of the gameboy speaker in the settings, but don't do for the time being. It currently sounds more like noise.", 33 | "You can disable this disclaimer in the settings, try searching for 'disable that annoying startup disclaimer'!" 34 | }; 35 | 36 | /// 37 | /// Called when the disclaimer finished displaying. 38 | /// 39 | public Action Complete; 40 | 41 | public DisclaimerSubScreen() 42 | { 43 | Child = textFlow = new OsuTextFlowContainer 44 | { 45 | RelativeSizeAxes = Axes.Both, 46 | Origin = Anchor.Centre, 47 | Anchor = Anchor.Centre, 48 | TextAnchor = Anchor.Centre, 49 | }; 50 | 51 | Child = new Container 52 | { 53 | AutoSizeAxes = Axes.Both, 54 | Origin = Anchor.Centre, 55 | Anchor = Anchor.Centre, 56 | Masking = true, 57 | CornerRadius = 16, 58 | Children = new Drawable[] 59 | { 60 | new Box 61 | { 62 | RelativeSizeAxes = Axes.Both, 63 | Colour = Color4.Gray.Opacity(0.4f) 64 | }, 65 | textFlow = new OsuTextFlowContainer 66 | { 67 | Margin = new MarginPadding(16), 68 | AutoSizeAxes = Axes.Both, 69 | Origin = Anchor.Centre, 70 | Anchor = Anchor.Centre, 71 | TextAnchor = Anchor.Centre, 72 | } 73 | } 74 | }; 75 | 76 | ValidForResume = false; 77 | } 78 | 79 | [BackgroundDependencyLoader] 80 | private void load(OsuColour color) 81 | { 82 | textFlow.AddIcon(FontAwesome.Solid.Wrench, t => 83 | { 84 | t.Font = t.Font.With(size: 50); 85 | }); 86 | 87 | textFlow.NewParagraph(); 88 | 89 | textFlow.AddParagraph("Disclaimer", t => 90 | { 91 | t.Font = t.Font.With(size: 30f); 92 | }); 93 | 94 | textFlow.AddParagraph("This is a WIP, so don't expect things to work as expected."); 95 | 96 | textFlow.AddParagraph("Tip: " + disclaimer_tips[RNG.Next(0, disclaimer_tips.Length)], t => 97 | { 98 | t.Colour = color.BlueLighter; 99 | }); 100 | 101 | textFlow.NewParagraph(); 102 | 103 | textFlow.AddParagraph("Press your (A) (B), (Select) (Start) button to skip this.", t => 104 | { 105 | t.Colour = color.YellowLighter; 106 | t.Font = t.Font.With(size: 12f); 107 | }); 108 | } 109 | 110 | public override void OnEntering(ScreenTransitionEvent last) 111 | { 112 | base.OnEntering(last); 113 | Scheduler.AddDelayed(schedulePush, 5000); 114 | } 115 | 116 | protected override bool OnClick(ClickEvent e) 117 | { 118 | Scheduler.CancelDelayedTasks(); 119 | schedulePush(); 120 | return base.OnClick(e); 121 | } 122 | 123 | public bool OnPressed(KeyBindingPressEvent action) 124 | { 125 | if (action.Action >= GamebosuAction.ButtonA && GamebosuAction.ButtonIncrementClockRate > action.Action) 126 | { 127 | Scheduler.CancelDelayedTasks(); 128 | schedulePush(); 129 | } 130 | 131 | return true; 132 | } 133 | 134 | private void schedulePush() 135 | { 136 | Content.ScaleTo(0.25f, 300, Easing.OutQuint) 137 | .FadeOut(300, Easing.Out) 138 | .OnComplete(t => Complete?.Invoke()); 139 | } 140 | 141 | public void OnReleased(KeyBindingReleaseEvent action) 142 | { 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/GamebosuMainScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Audio; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Textures; 8 | using osu.Framework.Platform; 9 | using osu.Framework.Screens; 10 | using osu.Game.Audio.Effects; 11 | using osu.Game.Rulesets.Gamebosu.Configuration; 12 | using osu.Game.Rulesets.Gamebosu.IO; 13 | using osu.Game.Rulesets.Gamebosu.UI.Input; 14 | 15 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 16 | { 17 | public partial class GamebosuMainScreen : ScreenWithCyclingBeatmapBackground 18 | { 19 | private readonly GamebosuScreenStack screenStack; 20 | 21 | private readonly GamebosuRuleset ruleset; 22 | 23 | private GamebosuConfigManager config; 24 | 25 | private AudioFilter lowPassFilter; 26 | 27 | public override bool HideOverlaysOnEnter => true; 28 | 29 | public GamebosuMainScreen(GamebosuRuleset ruleset) 30 | { 31 | this.ruleset = ruleset; 32 | InternalChild = new GamebosuInputManager(ruleset.RulesetInfo) 33 | { 34 | Child = screenStack = new GamebosuScreenStack() 35 | }; 36 | } 37 | 38 | [BackgroundDependencyLoader] 39 | private void load(AudioManager audio) 40 | { 41 | lowPassFilter = new AudioFilter(audio.TrackMixer); 42 | } 43 | 44 | protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) 45 | { 46 | var container = new DependencyContainer(parent); 47 | 48 | container.Cache(ruleset); 49 | container.Cache(config = (GamebosuConfigManager)container.Get().GetConfigFor(ruleset)); 50 | 51 | container.Get().AddTextureSource(new TextureLoaderStore(ruleset.CreateResourceStore())); 52 | 53 | container.Cache(new RomStore(container.Get())); 54 | 55 | return container; 56 | } 57 | 58 | public override void OnEntering(ScreenTransitionEvent last) 59 | { 60 | lowPassFilter.CutoffTo(1000, 1200, Easing.OutQuint); 61 | 62 | var displayDisclaimer = !config.Get(GamebosuSetting.DisableDisplayingThatAnnoyingDisclaimer); 63 | screenStack.Push(displayDisclaimer 64 | ? new DisclaimerSubScreen 65 | { 66 | Complete = () => screenStack.Push(new ListingSubScreen()) 67 | } 68 | : (GamebosuSubScreen)new ListingSubScreen()); 69 | 70 | base.OnEntering(last); 71 | } 72 | 73 | public override bool OnExiting(ScreenExitEvent next) 74 | { 75 | if (screenStack.CurrentScreen is GameplaySubScreen) 76 | { 77 | screenStack.Exit(); 78 | return true; 79 | } 80 | 81 | lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 300); 82 | 83 | return base.OnExiting(next); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/GamebosuScreenStack.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Screens; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 7 | { 8 | public partial class GamebosuScreenStack : ScreenStack 9 | { 10 | public GamebosuScreenStack() 11 | : base(true) 12 | { 13 | RelativeSizeAxes = Framework.Graphics.Axes.Both; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/GamebosuSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Graphics.Containers; 6 | using osu.Framework.Screens; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 9 | { 10 | public partial class GamebosuSubScreen : Container, IScreen 11 | { 12 | public override bool RemoveWhenNotAlive => false; 13 | 14 | public GamebosuSubScreen() 15 | { 16 | Anchor = Anchor.Centre; 17 | Origin = Anchor.Centre; 18 | RelativeSizeAxes = Axes.Both; 19 | } 20 | 21 | public virtual void OnEntering(ScreenTransitionEvent e) 22 | { 23 | Content 24 | .ScaleTo(0.5f) 25 | .ScaleTo(1, 500, Easing.OutQuint) 26 | .FadeInFromZero(500, Easing.OutQuint); 27 | } 28 | 29 | public virtual bool OnExiting(ScreenExitEvent e) 30 | { 31 | Content 32 | .ScaleTo(1) 33 | .ScaleTo(0.5f, 500, Easing.OutQuint) 34 | .FadeOutFromOne(500, Easing.OutQuint); 35 | 36 | return false; 37 | } 38 | 39 | public virtual void OnResuming(ScreenTransitionEvent e) 40 | { 41 | } 42 | 43 | public virtual void OnSuspending(ScreenTransitionEvent e) 44 | { 45 | } 46 | 47 | public bool ValidForResume { get; set; } = true; 48 | public bool ValidForPush { get; set; } = true; 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Gameplay/ClockRateIndicator.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Bindables; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Framework.Graphics.Sprites; 9 | using osu.Framework.Threading; 10 | using osu.Game.Graphics; 11 | using osu.Game.Graphics.Sprites; 12 | using osu.Game.Rulesets.Gamebosu.Configuration; 13 | using osuTK.Graphics; 14 | using System; 15 | 16 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Gameplay 17 | { 18 | public partial class ClockRateIndicator : VisibilityContainer 19 | { 20 | public readonly BindableDouble Rate = new BindableDouble(); 21 | 22 | private readonly OsuSpriteText rateText; 23 | 24 | private ScheduledDelegate hideDelegate; 25 | 26 | private Bindable lockClockRate; 27 | 28 | private const float icon_pos = 0.40f; 29 | 30 | public ClockRateIndicator() 31 | { 32 | AutoSizeAxes = Axes.Y; 33 | RelativeSizeAxes = Axes.X; 34 | 35 | InternalChildren = new Drawable[] 36 | { 37 | new SpriteIcon 38 | { 39 | Anchor = Anchor.BottomCentre, 40 | Origin = Anchor.BottomCentre, 41 | RelativePositionAxes = Axes.X, 42 | X = -icon_pos, 43 | Size = new osuTK.Vector2(20), 44 | Icon = FontAwesome.Solid.Bicycle 45 | }, 46 | new ValueGauge 47 | { 48 | RelativeSizeAxes = Axes.X, 49 | Anchor = Anchor.BottomCentre, 50 | Origin = Anchor.BottomCentre, 51 | Width = 0.75f, 52 | Height = 15, 53 | Value = new BindableDouble { BindTarget = Rate }, 54 | BarColour = Color4.White 55 | }, 56 | new SpriteIcon 57 | { 58 | Anchor = Anchor.BottomCentre, 59 | Origin = Anchor.BottomCentre, 60 | RelativePositionAxes = Axes.X, 61 | X = icon_pos, 62 | Size = new osuTK.Vector2(20), 63 | Icon = FontAwesome.Solid.Truck 64 | }, 65 | rateText = new OsuSpriteText 66 | { 67 | Anchor = Anchor.TopCentre, 68 | Origin = Anchor.TopCentre, 69 | Text = "1x", 70 | Font = OsuFont.GetFont(Typeface.Torus, 16, FontWeight.Bold, true), 71 | Margin = new MarginPadding { Bottom = 25 } 72 | } 73 | }; 74 | } 75 | 76 | [BackgroundDependencyLoader(true)] 77 | private void load(GamebosuConfigManager config) 78 | { 79 | Rate.BindValueChanged(updateValue, true); 80 | 81 | lockClockRate = config?.GetBindable(GamebosuSetting.LockClockRate); 82 | lockClockRate?.BindValueChanged(e => State.Value = e.NewValue ? Visibility.Hidden : Visibility.Visible, true); 83 | } 84 | 85 | private void updateValue(ValueChangedEvent e) 86 | { 87 | if (Rate.Disabled) 88 | return; 89 | 90 | rateText.Text = $"{Math.Round(e.NewValue, 2, MidpointRounding.AwayFromZero)}x"; 91 | Show(); 92 | } 93 | 94 | public void AdjustRate(double delta) 95 | { 96 | if (Rate.Disabled) 97 | return; 98 | 99 | try 100 | { 101 | Rate.Value += delta; 102 | } 103 | catch (Exception) 104 | { 105 | } 106 | } 107 | 108 | private void scheduleHide() 109 | { 110 | hideDelegate?.Cancel(); 111 | this.Delay(2000).Schedule(Hide, out hideDelegate); 112 | } 113 | 114 | protected override void PopIn() 115 | { 116 | Content.FadeIn(300, Easing.OutQuint); 117 | scheduleHide(); 118 | } 119 | 120 | protected override void PopOut() => Content.FadeOut(600, Easing.OutQuint); 121 | } 122 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Gameplay/ClockRateIndicatorControlReceptor.cs: -------------------------------------------------------------------------------- 1 | using osu.Framework.Graphics; 2 | using osu.Framework.Input.Bindings; 3 | using osu.Framework.Input.Events; 4 | using osu.Game.Rulesets.Gamebosu.UI.Input; 5 | using System; 6 | 7 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Gameplay 8 | { 9 | /// 10 | /// An always present drawable handling global actions for the clock rate indicator. 11 | /// This is required as hidden drawables won't receive keybindings actions. 12 | /// 13 | public partial class ClockRateIndicatorControlReceptor : Drawable, IKeyBindingHandler 14 | { 15 | public Action AdjustAction; 16 | 17 | public bool OnPressed(KeyBindingPressEvent action) 18 | { 19 | switch (action.Action) 20 | { 21 | case GamebosuAction.ButtonIncrementClockRate: 22 | AdjustAction(0.1); 23 | return true; 24 | 25 | case GamebosuAction.ButtonDecrementClockRate: 26 | AdjustAction(-0.1); 27 | return true; 28 | 29 | default: 30 | return false; 31 | } 32 | } 33 | 34 | public void OnReleased(KeyBindingReleaseEvent action) 35 | { 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Gameplay/ValueGauge.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Bindables; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Colour; 8 | using osu.Framework.Graphics.Containers; 9 | using osu.Framework.Graphics.Shapes; 10 | using osuTK.Graphics; 11 | using System; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Gameplay 14 | { 15 | public partial class ValueGauge : CompositeDrawable 16 | { 17 | public BindableDouble Value = new BindableDouble(0); 18 | 19 | private const double transition_time = 400; 20 | 21 | private readonly Container sliderContainer; 22 | 23 | private readonly Box bgBox; 24 | 25 | private readonly Box gaugeBox; 26 | 27 | public ColourInfo BackgroundColor 28 | { 29 | get => bgBox.Colour; 30 | set => bgBox.Colour = value; 31 | } 32 | 33 | public ColourInfo BarColour 34 | { 35 | get => gaugeBox.Colour; 36 | set => gaugeBox.Colour = value; 37 | } 38 | 39 | public ValueGauge() 40 | { 41 | Masking = true; 42 | CornerRadius = 8; 43 | InternalChildren = new Drawable[] 44 | { 45 | bgBox = new Box 46 | { 47 | RelativeSizeAxes = Axes.Both, 48 | Colour = Color4.Gray 49 | }, 50 | sliderContainer = new Container 51 | { 52 | Masking = true, 53 | CornerRadius = 8, 54 | RelativeSizeAxes = Axes.Both, 55 | Child = gaugeBox = new Box 56 | { 57 | RelativeSizeAxes = Axes.Both, 58 | Colour = Color4.White, 59 | } 60 | } 61 | }; 62 | } 63 | 64 | [BackgroundDependencyLoader] 65 | private void load() 66 | { 67 | Value.BindValueChanged(updateGauge, true); 68 | } 69 | 70 | private void updateGauge(ValueChangedEvent e) 71 | { 72 | var width = (float)Math.Max(0, (e.NewValue / Value.MaxValue)); 73 | sliderContainer.ResizeWidthTo(width, 1.5 * transition_time, Easing.OutQuint); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/GameplaySubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using Emux.GameBoy.Cartridge; 5 | using osu.Framework.Allocation; 6 | using osu.Framework.Bindables; 7 | using osu.Framework.Graphics; 8 | using osu.Framework.Graphics.Containers; 9 | using osu.Game.Rulesets.Gamebosu.Configuration; 10 | using osu.Game.Rulesets.Gamebosu.UI.Gameboy; 11 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Gameplay; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 14 | { 15 | public partial class GameplaySubScreen : GamebosuSubScreen 16 | { 17 | private DrawableGameboy gameboy; 18 | private Container container; 19 | private ClockRateIndicator indicator; 20 | 21 | private readonly ICartridge cartridge; 22 | 23 | private Bindable gameboyScale; 24 | 25 | public GameplaySubScreen(ICartridge cart) 26 | { 27 | cartridge = cart; 28 | } 29 | 30 | [BackgroundDependencyLoader] 31 | private void load(GamebosuConfigManager config) 32 | { 33 | Children = new Drawable[] 34 | { 35 | container = new Container 36 | { 37 | Anchor = Anchor.Centre, 38 | Origin = Anchor.Centre, 39 | AutoSizeAxes = Axes.Both, 40 | Child = gameboy = new DrawableGameboy(cartridge) 41 | { 42 | Anchor = Anchor.Centre, 43 | Origin = Anchor.Centre, 44 | }, 45 | }, 46 | new ClockRateIndicatorControlReceptor 47 | { 48 | AdjustAction = (f) => indicator.AdjustRate(f), 49 | }, 50 | indicator = new ClockRateIndicator 51 | { 52 | Anchor = Anchor.BottomCentre, 53 | Origin = Anchor.BottomCentre, 54 | Margin = new MarginPadding { Bottom = 20 }, 55 | Alpha = 0, 56 | } 57 | }; 58 | 59 | gameboyScale = config.GetBindable(GamebosuSetting.GameboyScale); 60 | gameboyScale.BindValueChanged(e => container.ScaleTo(e.NewValue, 400, Easing.OutQuint), true); 61 | config.BindWith(GamebosuSetting.ClockRate, indicator.Rate); 62 | 63 | gameboy.Start(); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Listing/ListingHeader.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Extensions.Color4Extensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Framework.Graphics.Shapes; 9 | using osu.Game.Graphics; 10 | using osu.Game.Graphics.Sprites; 11 | using osu.Game.Overlays; 12 | using osu.Game.Screens; 13 | using osuTK; 14 | 15 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Listing 16 | { 17 | public partial class ListingHeader : Container 18 | { 19 | public const float HEIGHT = 80; 20 | 21 | private const float spacing = 6; 22 | 23 | private readonly OsuSpriteText dot; 24 | private readonly OsuSpriteText romListing; 25 | 26 | public ListingHeader() 27 | { 28 | RelativeSizeAxes = Axes.X; 29 | Height = HEIGHT; 30 | Padding = new MarginPadding { Left = -WaveOverlayContainer.WIDTH_PADDING }; 31 | 32 | Children = new Drawable[] 33 | { 34 | new Box 35 | { 36 | RelativeSizeAxes = Axes.Both, 37 | Colour = Color4Extensions.FromHex(@"#1f1921"), 38 | }, 39 | new Container 40 | { 41 | Anchor = Anchor.CentreLeft, 42 | Origin = Anchor.CentreLeft, 43 | RelativeSizeAxes = Axes.Both, 44 | Padding = new MarginPadding { Left = WaveOverlayContainer.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING }, 45 | Children = new Drawable[] 46 | { 47 | new FillFlowContainer 48 | { 49 | AutoSizeAxes = Axes.Both, 50 | Spacing = new Vector2(spacing, 0), 51 | Anchor = Anchor.CentreLeft, 52 | Origin = Anchor.CentreLeft, 53 | Direction = FillDirection.Horizontal, 54 | Children = new Drawable[] 55 | { 56 | new GamebosuRuleset().CreateIcon().With(t => 57 | { 58 | t.Anchor = Anchor.CentreLeft; 59 | t.Origin = Anchor.CentreLeft; 60 | t.Scale = new Vector2(0.75f); 61 | t.Margin = new MarginPadding { Right = 10 }; 62 | }), 63 | new OsuSpriteText 64 | { 65 | Anchor = Anchor.CentreLeft, 66 | Origin = Anchor.CentreLeft, 67 | Font = OsuFont.GetFont(size: 24), 68 | Text = "gamebosu" 69 | }, 70 | dot = new OsuSpriteText 71 | { 72 | Anchor = Anchor.CentreLeft, 73 | Origin = Anchor.CentreLeft, 74 | Font = OsuFont.GetFont(size: 48), 75 | Text = "·" 76 | }, 77 | romListing = new OsuSpriteText 78 | { 79 | Anchor = Anchor.CentreLeft, 80 | Origin = Anchor.CentreLeft, 81 | Font = OsuFont.GetFont(size: 24), 82 | Text = "rom listing" 83 | } 84 | } 85 | }, 86 | }, 87 | }, 88 | }; 89 | 90 | } 91 | 92 | [BackgroundDependencyLoader] 93 | private void load(OsuColour colours) 94 | { 95 | romListing.Colour = dot.Colour = colours.Yellow; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Listing/ListingPanel.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Game.Graphics.Containers; 5 | using osu.Game.Graphics.UserInterface; 6 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Selection; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Listing 9 | { 10 | public partial class ListingPanel : OsuClickableContainer 11 | { 12 | public ListingPanel(string romName) 13 | : base(HoverSampleSet.Button) 14 | { 15 | AutoSizeAxes = Framework.Graphics.Axes.X; 16 | Height = 380; 17 | Child = new SelectionCard(romName); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Listing/NoRomAvailablePopup.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Graphics.Containers; 6 | using osu.Framework.Graphics.Shapes; 7 | using osu.Framework.Graphics.Sprites; 8 | using osu.Game.Graphics; 9 | using osu.Game.Graphics.Sprites; 10 | 11 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Listing 12 | { 13 | public partial class NoRomAvailablePopup : VisibilityContainer 14 | { 15 | private const double fade_time = 300; 16 | private const Easing easing = Easing.OutQuint; 17 | 18 | private const int sprite_size = 120; 19 | 20 | protected override bool StartHidden => true; 21 | 22 | public NoRomAvailablePopup() 23 | { 24 | AutoSizeAxes = Axes.Both; 25 | Anchor = Anchor.Centre; 26 | Origin = Anchor.Centre; 27 | Masking = true; 28 | CornerRadius = 16; 29 | 30 | Children = new Drawable[] 31 | { 32 | new Box 33 | { 34 | Colour = Colour4.Gray.Opacity(0.4f), 35 | RelativeSizeAxes = Axes.Both 36 | }, 37 | new FillFlowContainer 38 | { 39 | AutoSizeAxes = Axes.Both, 40 | Anchor = Anchor.Centre, 41 | Origin = Anchor.Centre, 42 | Margin = new MarginPadding(16), 43 | Spacing = new osuTK.Vector2(0, 10), 44 | Direction = FillDirection.Vertical, 45 | Children = new Drawable[] 46 | { 47 | new SpriteIcon 48 | { 49 | Icon = FontAwesome.Solid.SadCry, 50 | Anchor = Anchor.Centre, 51 | Origin = Anchor.Centre, 52 | Size = new osuTK.Vector2(sprite_size) 53 | }, 54 | new OsuSpriteText 55 | { 56 | Anchor = Anchor.Centre, 57 | Origin = Anchor.Centre, 58 | Font = OsuFont.GetFont(Typeface.Torus, 28, FontWeight.Bold), 59 | Text = "Sadly there's no usable ROM avalaible ...", 60 | }, 61 | new OsuSpriteText 62 | { 63 | Anchor = Anchor.Centre, 64 | Origin = Anchor.Centre, 65 | Font = OsuFont.GetFont(Typeface.Torus, 18, FontWeight.Regular), 66 | Text = "Go grab some ROM files and put 'em in the roms folder", 67 | }, 68 | new OsuSpriteText 69 | { 70 | Anchor = Anchor.Centre, 71 | Origin = Anchor.Centre, 72 | Font = OsuFont.GetFont(Typeface.Torus, 16, FontWeight.Regular), 73 | Text = "(You can open the roms folder from the settings or drag n' drop the rom files into osu! window)", 74 | } 75 | } 76 | } 77 | }; 78 | } 79 | 80 | protected override void PopIn() => Content.FadeIn(2 * fade_time, easing); 81 | 82 | protected override void PopOut() => Content.FadeOut(2 * fade_time, easing); 83 | } 84 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Listing/RomImportHandler.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Game.Database; 7 | using osu.Game.Rulesets.Gamebosu.IO; 8 | using System.Collections.Generic; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Threading.Tasks; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Listing 14 | { 15 | /// 16 | /// Handles import of GB / GBC files. 17 | /// 18 | public partial class RomImportHandler : Component, ICanAcceptFiles 19 | { 20 | [Resolved] 21 | private ListingSubScreen listing { get; set; } 22 | 23 | [Resolved] 24 | private RomStore store { get; set; } 25 | 26 | public IEnumerable HandledExtensions => RomStore.RecognizedExtensions; 27 | 28 | public Task Import(params string[] paths) => Import(paths.Select(path => new ImportTask(path)).ToArray(), default); 29 | 30 | public Task Import(ImportTask[] tasks, ImportParameters parameters) => Task.Run(() => 31 | { 32 | foreach (var task in tasks) 33 | { 34 | var file = new FileInfo(task.Path); 35 | if (!File.Exists(store.Storage.GetFullPath(file.Name))) 36 | file.CopyTo(store.Storage.GetFullPath(file.Name)); 37 | } 38 | 39 | Schedule(listing.Refresh); 40 | }); 41 | } 42 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Listing/RomListing.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Bindables; 5 | using osu.Framework.Extensions.IEnumerableExtensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Game.Graphics.Containers; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | 13 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Listing 14 | { 15 | public partial class RomListing : Container 16 | { 17 | private readonly Bindable> availableRoms = new Bindable>(Enumerable.Empty()); 18 | 19 | private readonly FillFlowContainer fillFlowContainer; 20 | private readonly OsuScrollContainer scrollContainer; 21 | private readonly NoRomAvailablePopup romNotFound; 22 | 23 | /// 24 | /// A callback called upon selection of a ROM by the user. 25 | /// 26 | public Action RomSelected; 27 | 28 | public IEnumerable AvailableRoms 29 | { 30 | set 31 | { 32 | if (!Enumerable.SequenceEqual(value, availableRoms.Value)) 33 | availableRoms.Value = value; 34 | } 35 | } 36 | 37 | public RomListing() 38 | { 39 | Child = new Container 40 | { 41 | RelativeSizeAxes = Axes.Both, 42 | Children = new Drawable[] 43 | { 44 | romNotFound = new NoRomAvailablePopup(), 45 | scrollContainer = new OsuScrollContainer(Direction.Vertical) 46 | { 47 | RelativeSizeAxes = Axes.Both, 48 | Child = fillFlowContainer = new FillFlowContainer 49 | { 50 | RelativeSizeAxes = Axes.X, 51 | AutoSizeAxes = Axes.Y, 52 | Padding = new MarginPadding { Horizontal = 15 }, 53 | Spacing = new osuTK.Vector2(15, 0), 54 | } 55 | }, 56 | } 57 | }; 58 | } 59 | 60 | protected override void LoadComplete() 61 | { 62 | availableRoms.BindValueChanged(refreshDisplay, true); 63 | base.LoadComplete(); 64 | } 65 | 66 | private void refreshDisplay(ValueChangedEvent> roms) 67 | { 68 | fillFlowContainer.Clear(); 69 | romNotFound.State.Value = roms.NewValue.Count() > 0 ? Visibility.Hidden : Visibility.Visible; 70 | roms.NewValue.ForEach(each => fillFlowContainer.Add(new ListingPanel(each) 71 | { 72 | Action = () => RomSelected(each), 73 | Margin = new MarginPadding { Top = 5 } 74 | })); 75 | } 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/ListingSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Extensions.Color4Extensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Shapes; 8 | using osu.Framework.Screens; 9 | using osu.Framework.Threading; 10 | using osu.Game.Graphics.Containers; 11 | using osu.Game.Rulesets.Gamebosu.IO; 12 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Listing; 13 | 14 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 15 | { 16 | [Cached] 17 | public partial class ListingSubScreen : GamebosuSubScreen 18 | { 19 | private readonly RomListing listing; 20 | 21 | private readonly RomImportHandler romImportHandler; 22 | 23 | private readonly WaveContainer waveContainer; 24 | 25 | [Resolved] 26 | private RomStore roms { get; set; } 27 | 28 | [Resolved(CanBeNull = true)] 29 | private OsuGame game { get; set; } 30 | 31 | private ScheduledDelegate refreshDelegate; 32 | 33 | public ListingSubScreen() 34 | { 35 | Anchor = Anchor.Centre; 36 | Origin = Anchor.Centre; 37 | RelativeSizeAxes = Axes.Both; 38 | 39 | var backgroundColour = Color4Extensions.FromHex(@"3e3a44"); 40 | 41 | InternalChild = waveContainer = new ListingWaveContainer 42 | { 43 | RelativeSizeAxes = Axes.Both, 44 | Children = new Drawable[] 45 | { 46 | romImportHandler = new RomImportHandler(), 47 | new Box 48 | { 49 | RelativeSizeAxes = Axes.Both, 50 | Colour = backgroundColour, 51 | }, 52 | listing = new RomListing 53 | { 54 | RelativeSizeAxes = Axes.Both, 55 | RomSelected = Prepare, 56 | Padding = new MarginPadding { Top = ListingHeader.HEIGHT }, 57 | }, 58 | new ListingHeader() 59 | } 60 | }; 61 | } 62 | 63 | /// 64 | /// Triggers a refresh of the rom listing. 65 | /// 66 | public void Refresh() 67 | { 68 | refreshDelegate?.Cancel(); 69 | listing.AvailableRoms = roms.GetAvailableResources(); 70 | refreshDelegate = Scheduler.AddDelayed(Refresh, 2500); 71 | } 72 | 73 | protected void Prepare(string clicked) 74 | { 75 | roms.GetAsync(clicked).ContinueWith(rom => 76 | { 77 | Schedule(() => 78 | { 79 | waveContainer.Hide(); 80 | Scheduler.AddDelayed(() => this.Push(new GameplaySubScreen(rom.Result)), 500); 81 | }); 82 | }); 83 | } 84 | 85 | public override void OnEntering(ScreenTransitionEvent last) 86 | { 87 | game?.RegisterImportHandler(romImportHandler); 88 | waveContainer.Show(); 89 | Refresh(); 90 | } 91 | 92 | public override void OnSuspending(ScreenTransitionEvent next) 93 | { 94 | waveContainer.Hide(); 95 | base.OnSuspending(next); 96 | } 97 | 98 | public override void OnResuming(ScreenTransitionEvent last) 99 | { 100 | waveContainer.Show(); 101 | base.OnResuming(last); 102 | } 103 | 104 | public override bool OnExiting(ScreenExitEvent next) 105 | { 106 | game.UnregisterImportHandler(romImportHandler); 107 | waveContainer.Hide(); 108 | return base.OnExiting(next); 109 | } 110 | 111 | private partial class ListingWaveContainer : WaveContainer 112 | { 113 | public ListingWaveContainer() 114 | { 115 | FirstWaveColour = Color4Extensions.FromHex(@"654d8c"); 116 | SecondWaveColour = Color4Extensions.FromHex(@"554075"); 117 | ThirdWaveColour = Color4Extensions.FromHex(@"44325e"); 118 | FourthWaveColour = Color4Extensions.FromHex(@"392850"); 119 | } 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/MovingNotice.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Extensions.Color4Extensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Framework.Graphics.Shapes; 9 | using osu.Framework.Graphics.Sprites; 10 | using osu.Game.Graphics.Containers; 11 | using osu.Game.Overlays; 12 | using osuTK.Graphics; 13 | 14 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 15 | { 16 | public partial class MovingNotice : Container 17 | { 18 | private readonly OsuTextFlowContainer textFlow; 19 | 20 | public MovingNotice() 21 | { 22 | Masking = true; 23 | CornerRadius = 16; 24 | 25 | Children = new Drawable[] 26 | { 27 | new Box 28 | { 29 | RelativeSizeAxes = Axes.Both, 30 | Colour = Color4.Gray.Opacity(0.4f) 31 | }, 32 | textFlow = new OsuTextFlowContainer 33 | { 34 | RelativeSizeAxes = Axes.Both, 35 | Origin = Anchor.Centre, 36 | Anchor = Anchor.Centre, 37 | TextAnchor = Anchor.Centre, 38 | } 39 | }; 40 | } 41 | 42 | [BackgroundDependencyLoader] 43 | private void load(SettingsOverlay settings) 44 | { 45 | textFlow.AddIcon(FontAwesome.Solid.DoorOpen, t => 46 | { 47 | t.Font = t.Font.With(size: 50); 48 | }); 49 | 50 | textFlow.NewLine(); 51 | 52 | textFlow.AddParagraph("gamebosu! moved to the settings overlay", t => 53 | { 54 | t.Font = t.Font.With(size: 24); 55 | t.Colour = Color4.Yellow; 56 | }); 57 | textFlow.AddParagraph("Open the settings to access the rom listing", t => t.Font = t.Font.With(size: 16)); 58 | textFlow.AddParagraph("Search for \"open rom listing\" ", t => t.Font = t.Font.With(size: 12)); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/RomSelectionSubScreen.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Graphics; 6 | using osu.Framework.Graphics.Containers; 7 | using osu.Framework.Screens; 8 | using osu.Framework.Threading; 9 | using osu.Game.Graphics; 10 | using osu.Game.Graphics.Sprites; 11 | using osu.Game.Rulesets.Gamebosu.IO; 12 | using osu.Game.Rulesets.Gamebosu.UI.Screens.Selection; 13 | using osuTK; 14 | using System.Linq; 15 | 16 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 17 | { 18 | public partial class RomSelectionSubScreen : GamebosuSubScreen 19 | { 20 | private RomSelector romSelector; 21 | private RomStore store; 22 | 23 | private ScheduledDelegate romListUpdateDelegate; 24 | 25 | [BackgroundDependencyLoader(true)] 26 | private void load(RomStore roms, DrawableGamebosuRuleset drawableRuleset) 27 | { 28 | Child = new FillFlowContainer 29 | { 30 | Margin = new MarginPadding { Top = 100 }, 31 | RelativeSizeAxes = Axes.Both, 32 | Anchor = Anchor.TopCentre, 33 | Origin = Anchor.TopCentre, 34 | Spacing = new Vector2(0, 20), 35 | Direction = FillDirection.Vertical, 36 | Children = new Drawable[] 37 | { 38 | (drawableRuleset?.Ruleset ?? new GamebosuRuleset()).CreateIcon() 39 | .With(t => t.Anchor = Anchor.TopCentre) 40 | .With(t => t.Origin = Anchor.TopCentre), 41 | 42 | new OsuSpriteText 43 | { 44 | Anchor = Anchor.TopCentre, 45 | Origin = Anchor.TopCentre, 46 | Text = "Game selection", 47 | Font = OsuFont.GetFont(Typeface.Torus, 32, FontWeight.Bold) 48 | }, 49 | romSelector = new RomSelector 50 | { 51 | RelativeSizeAxes = Axes.X, 52 | Height = 300, 53 | RomSelected = loadRom, 54 | AvailableRoms = { Value = roms.GetAvailableResources() } 55 | }, 56 | } 57 | }; 58 | 59 | store = roms; 60 | } 61 | 62 | private void loadRom(string romName) 63 | { 64 | if (romName == null) 65 | { 66 | romSelector.MarkUnavailable(); 67 | return; 68 | } 69 | 70 | store.GetAsync(romName).ContinueWith(t => 71 | { 72 | if (t.Result != null) 73 | this.Push(new GameplaySubScreen(t.Result)); 74 | else 75 | romSelector.MarkUnavailable(); 76 | }); 77 | } 78 | 79 | private void fetchRomList() 80 | { 81 | var list = store.GetAvailableResources(); 82 | 83 | if (!Enumerable.SequenceEqual(list, romSelector.AvailableRoms.Value)) 84 | romSelector.AvailableRoms.Value = list; 85 | } 86 | 87 | public override void OnEntering(ScreenTransitionEvent last) 88 | { 89 | romListUpdateDelegate = Scheduler.AddDelayed(fetchRomList, 5000, true); 90 | base.OnEntering(last); 91 | } 92 | 93 | public override bool OnExiting(ScreenExitEvent next) 94 | { 95 | romListUpdateDelegate?.Cancel(); 96 | return base.OnExiting(next); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/ScreenWithCyclingBeatmapBackground.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Bindables; 5 | using osu.Game.Beatmaps; 6 | using osu.Game.Screens.Play; 7 | 8 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens 9 | { 10 | /// 11 | /// A screen with a blured background which automatically cycles to the current beatmap's background upon changing beatmap background. 12 | /// 13 | public partial class ScreenWithCyclingBeatmapBackground : ScreenWithBeatmapBackground 14 | { 15 | private const float blur_factor = 20; 16 | 17 | private void updateBackground(ValueChangedEvent beatmap) 18 | { 19 | Schedule(() => 20 | { 21 | ApplyToBackground(background => 22 | { 23 | background.BlurAmount.Value = blur_factor; 24 | background.Beatmap = beatmap.NewValue; 25 | }); 26 | }); 27 | } 28 | 29 | protected override void LoadComplete() 30 | { 31 | Beatmap.BindValueChanged(updateBackground, true); 32 | base.LoadComplete(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Selection/NoRomAvailableMessage.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Graphics; 5 | using osu.Framework.Graphics.Containers; 6 | using osu.Framework.Graphics.Sprites; 7 | using osu.Game.Graphics; 8 | using osu.Game.Graphics.Sprites; 9 | 10 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Selection 11 | { 12 | public partial class NoRomAvailableMessage : VisibilityContainer 13 | { 14 | private const int sprite_size = 120; 15 | private const int text_padding = 20; 16 | 17 | protected override bool StartHidden => true; 18 | 19 | public NoRomAvailableMessage() 20 | { 21 | RelativeSizeAxes = Axes.Y; 22 | AutoSizeAxes = Axes.X; 23 | Anchor = Anchor.Centre; 24 | Origin = Anchor.Centre; 25 | 26 | Children = new Drawable[] 27 | { 28 | new SpriteIcon 29 | { 30 | Icon = FontAwesome.Solid.SadCry, 31 | RelativeSizeAxes = Axes.Y, 32 | Anchor = Anchor.Centre, 33 | Origin = Anchor.Centre, 34 | Size = new osuTK.Vector2(sprite_size) 35 | }, 36 | new OsuSpriteText 37 | { 38 | Anchor = Anchor.BottomCentre, 39 | Origin = Anchor.BottomCentre, 40 | Margin = new MarginPadding() { Bottom = text_padding }, 41 | Font = OsuFont.GetFont(Typeface.Torus, 28, FontWeight.Bold), 42 | Text = "Sadly there's no usable ROM avalaible ...", 43 | }, 44 | new OsuSpriteText 45 | { 46 | Anchor = Anchor.BottomCentre, 47 | Origin = Anchor.BottomCentre, 48 | Font = OsuFont.GetFont(Typeface.Torus, 16, FontWeight.Regular), 49 | Text = "Go grab some ROM files and put 'em in the roms folder", 50 | } 51 | }; 52 | } 53 | 54 | protected override void PopIn() => Content.FadeIn(2 * RomSelector.FADE_TIME, RomSelector.EASING); 55 | 56 | protected override void PopOut() => Content.FadeOut(2 * RomSelector.FADE_TIME, RomSelector.EASING); 57 | } 58 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Selection/RomSelector.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Audio; 6 | using osu.Framework.Audio.Sample; 7 | using osu.Framework.Bindables; 8 | using osu.Framework.Graphics; 9 | using osu.Framework.Graphics.Containers; 10 | using osu.Framework.Graphics.Sprites; 11 | using osu.Framework.Input.Bindings; 12 | using osu.Framework.Input.Events; 13 | using osu.Game.Rulesets.Gamebosu.UI.Input; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Linq; 17 | 18 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Selection 19 | { 20 | public partial class RomSelector : CompositeDrawable, IKeyBindingHandler 21 | { 22 | public const double FADE_TIME = 300; 23 | public const Easing EASING = Easing.OutQuint; 24 | 25 | private readonly Container selectionContainer; 26 | private readonly SpriteIcon selectionLeft; 27 | private readonly SpriteIcon selectionRight; 28 | private readonly NoRomAvailableMessage noRomPopup; 29 | 30 | private Sample selectSample; 31 | private Sample confirmSelectSample; 32 | 33 | private BindableInt selection = new BindableInt(0) 34 | { 35 | MinValue = 0, 36 | }; 37 | 38 | /// 39 | /// Called when the ROM has been selected. 40 | /// 41 | public Action RomSelected; 42 | 43 | /// 44 | /// The available roms for use. 45 | /// Will update the selectable rom cards when updated. 46 | /// 47 | public readonly Bindable> AvailableRoms = new Bindable>(Enumerable.Empty()); 48 | 49 | /// 50 | /// Displays an error popup on the selected card indicating that the coresponding cartridge is unavailable. 51 | /// 52 | public void MarkUnavailable() => Scheduler.Add(() => getDrawableCardAtIndex(selection.Value)?.MarkUnavailable()); 53 | 54 | public RomSelector() 55 | { 56 | RelativeSizeAxes = Axes.Both; 57 | 58 | InternalChild = new FillFlowContainer 59 | { 60 | Origin = Anchor.Centre, 61 | Anchor = Anchor.Centre, 62 | RelativeSizeAxes = Axes.Both, 63 | Direction = FillDirection.Vertical, 64 | Spacing = new osuTK.Vector2(0, 0.1f), 65 | Children = new Drawable[] 66 | { 67 | new Container 68 | { 69 | RelativeSizeAxes = Axes.X, 70 | Height = 400, 71 | Children = new Drawable[] 72 | { 73 | noRomPopup = new NoRomAvailableMessage(), 74 | selectionLeft = new SpriteIcon 75 | { 76 | Anchor = Anchor.Centre, 77 | Origin = Anchor.Centre, 78 | RelativePositionAxes = Axes.X, 79 | X = -0.25f, 80 | Size = new osuTK.Vector2(40), 81 | Icon = FontAwesome.Solid.ChevronLeft, 82 | Alpha = 0, 83 | }, 84 | selectionContainer = new Container 85 | { 86 | Anchor = Anchor.Centre, 87 | Origin = Anchor.Centre, 88 | RelativeSizeAxes = Axes.Both, 89 | }, 90 | selectionRight = new SpriteIcon 91 | { 92 | Anchor = Anchor.Centre, 93 | Origin = Anchor.Centre, 94 | RelativePositionAxes = Axes.X, 95 | X = 0.25f, 96 | Size = new osuTK.Vector2(40), 97 | Icon = FontAwesome.Solid.ChevronRight, 98 | Alpha = 0, 99 | }, 100 | } 101 | }, 102 | } 103 | }; 104 | } 105 | 106 | [BackgroundDependencyLoader] 107 | private void load(AudioManager audio) 108 | { 109 | selectSample = audio.Samples.Get("UI/generic-hover-soft"); 110 | confirmSelectSample = audio.Samples.Get("UI/notification-pop-in"); 111 | 112 | selection.BindValueChanged(updateSelection, true); 113 | 114 | AvailableRoms.BindValueChanged(roms => 115 | { 116 | noRomPopup.State.Value = roms.NewValue.Count() > 0 ? Visibility.Hidden : Visibility.Visible; 117 | 118 | selectionContainer.Clear(); 119 | selectionContainer.AddRange(roms.NewValue.Select(rom => new SelectionCard(rom) 120 | { 121 | Anchor = Anchor.Centre, 122 | Origin = Anchor.Centre, 123 | Alpha = 0, 124 | })); 125 | 126 | selection.MaxValue = (roms.NewValue.Count() - 1) > 0 ? (roms.NewValue.Count() - 1) : 0; 127 | selection.TriggerChange(); 128 | }, true); 129 | 130 | selection.BindValueChanged(updateSelectedDrawableCard, true); 131 | } 132 | 133 | /// 134 | /// Updates the arrows from the selector, depending of whether there are other roms available. 135 | /// 136 | private void updateSelection(ValueChangedEvent selection) 137 | { 138 | selectSample?.Play(); 139 | 140 | selectionLeft.FadeIn(FADE_TIME, EASING); 141 | selectionRight.FadeIn(FADE_TIME, EASING); 142 | 143 | if (selection.NewValue == this.selection.MaxValue) 144 | selectionRight.FadeOut(FADE_TIME, EASING); 145 | 146 | if (selection.NewValue == 0) 147 | selectionLeft.FadeOut(FADE_TIME, EASING); 148 | } 149 | 150 | /// 151 | /// Set the current selected rom card as the one at the given index. 152 | /// 153 | private void setSelection(int idx) 154 | { 155 | selection.Value += idx; 156 | 157 | if (idx == 1) 158 | { 159 | selectionRight 160 | .ScaleTo(1.5f, 150, Easing.OutQuint) 161 | .Then(0) 162 | .ScaleTo(1, 150, Easing.OutQuint); 163 | } 164 | else 165 | { 166 | selectionLeft 167 | .ScaleTo(1.5f, 150, Easing.OutQuint) 168 | .Then(0) 169 | .ScaleTo(1, 150, Easing.OutQuint); 170 | } 171 | } 172 | 173 | /// 174 | /// Updates the visibility of the currently selected drawable card. 175 | /// 176 | private void updateSelectedDrawableCard(ValueChangedEvent e) 177 | { 178 | getDrawableCardAtIndex(e.OldValue)?.FadeOut(FADE_TIME, EASING); 179 | getDrawableCardAtIndex(e.NewValue)?.FadeIn(2 * FADE_TIME, EASING); 180 | } 181 | 182 | private SelectionCard getDrawableCardAtIndex(int index) => (selectionContainer.Count < index || selectionContainer.Count == 0) ? null : selectionContainer[index]; 183 | 184 | public bool OnPressed(KeyBindingPressEvent action) 185 | { 186 | switch (action.Action) 187 | { 188 | case GamebosuAction.DPadRight: 189 | setSelection(1); 190 | break; 191 | 192 | case GamebosuAction.DPadLeft: 193 | setSelection(-1); 194 | break; 195 | 196 | case GamebosuAction.ButtonA: 197 | case GamebosuAction.ButtonStart: 198 | case GamebosuAction.ButtonSelect: 199 | var rom = AvailableRoms.Value.ElementAtOrDefault(selection.Value); 200 | 201 | if (rom == null) 202 | goto default; 203 | 204 | confirmSelectSample?.Play(); 205 | RomSelected?.Invoke(rom); 206 | break; 207 | 208 | default: 209 | break; 210 | } 211 | 212 | return true; 213 | } 214 | 215 | public void OnReleased(KeyBindingReleaseEvent action) 216 | { 217 | } 218 | } 219 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/UI/Screens/Selection/SelectionCard.cs: -------------------------------------------------------------------------------- 1 | // gamebosu! ruleset. Copyright Lucas ARRIESSE aka Game4all. Licensed under GPLv3. 2 | // See LICENSE at root of repo for more information on licensing. 3 | 4 | using osu.Framework.Allocation; 5 | using osu.Framework.Extensions.Color4Extensions; 6 | using osu.Framework.Graphics; 7 | using osu.Framework.Graphics.Containers; 8 | using osu.Framework.Graphics.Shapes; 9 | using osu.Framework.Graphics.Sprites; 10 | using osu.Framework.Graphics.Textures; 11 | using osu.Game.Graphics; 12 | using osu.Game.Graphics.Sprites; 13 | using osu.Game.Rulesets.Gamebosu.Graphics; 14 | using osu.Game.Rulesets.Gamebosu.IO; 15 | using osuTK.Graphics; 16 | using System.Linq; 17 | 18 | namespace osu.Game.Rulesets.Gamebosu.UI.Screens.Selection 19 | { 20 | public partial class SelectionCard : CompositeDrawable 21 | { 22 | private readonly Sprite cartridge; 23 | private readonly SpriteIcon loadFailedIcon; 24 | private readonly OsuSpriteText loadFailedText; 25 | private readonly OsuSpriteText romNameText; 26 | 27 | public SelectionCard(string romName) 28 | { 29 | Anchor = Anchor.Centre; 30 | Origin = Anchor.Centre; 31 | RelativeSizeAxes = Axes.Y; 32 | AutoSizeAxes = Axes.X; 33 | Masking = true; 34 | CornerRadius = 15; 35 | 36 | InternalChild = new Container 37 | { 38 | Anchor = Anchor.Centre, 39 | Origin = Anchor.Centre, 40 | RelativeSizeAxes = Axes.Y, 41 | AutoSizeAxes = Axes.X, 42 | Children = new Drawable[] 43 | { 44 | new Box 45 | { 46 | RelativeSizeAxes = Axes.Both, 47 | Colour = Color4.Gray.Opacity(0.4f) 48 | }, 49 | new FillFlowContainer 50 | { 51 | RelativeSizeAxes = Axes.Y, 52 | AutoSizeAxes = Axes.X, 53 | Anchor = Anchor.TopLeft, 54 | Origin = Anchor.TopLeft, 55 | Direction = FillDirection.Vertical, 56 | Spacing = new osuTK.Vector2(0, 0.10f), 57 | Children = new Drawable[] 58 | { 59 | new Container 60 | { 61 | Masking = true, 62 | RelativeSizeAxes = Axes.Y, 63 | Height = 0.75f, 64 | Width = 300, 65 | Margin = new MarginPadding { Horizontal = 10, Vertical = 10 }, 66 | Children = new Drawable[] 67 | { 68 | new Box 69 | { 70 | RelativeSizeAxes = Axes.Both, 71 | Colour = Color4.Black.Opacity(0.6f) 72 | }, 73 | loadFailedText = new OsuSpriteText 74 | { 75 | Anchor = Anchor.BottomCentre, 76 | Origin = Anchor.BottomCentre, 77 | Margin = new MarginPadding { Bottom = 10 }, 78 | Font = OsuFont.GetFont(Typeface.Torus, 20, FontWeight.Bold), 79 | Text = "Failed to load cartridge!", 80 | Colour = Color4.Red, 81 | Alpha = 0, 82 | }, 83 | cartridge = new Sprite 84 | { 85 | Anchor = Anchor.Centre, 86 | Origin = Anchor.Centre, 87 | Scale = new osuTK.Vector2(2) 88 | }, 89 | loadFailedIcon = new SpriteIcon 90 | { 91 | Icon = OsuIcon.CrossCircle, 92 | Anchor = Anchor.Centre, 93 | Origin = Anchor.Centre, 94 | Colour = Color4.Red.Opacity(0.9f), 95 | Size = new osuTK.Vector2(160), 96 | Alpha = 0 97 | }, 98 | }, 99 | CornerRadius = 15 100 | }, 101 | new Container 102 | { 103 | Anchor = Anchor.TopLeft, 104 | Origin = Anchor.TopLeft, 105 | Width = 300, 106 | RelativeSizeAxes = Axes.Y, 107 | Masking = true, 108 | CornerRadius = 15, 109 | Height = 0.15f, 110 | Margin = new MarginPadding { Horizontal = 10, Vertical = 10 }, 111 | Children = new Drawable[] 112 | { 113 | new Box 114 | { 115 | RelativeSizeAxes = Axes.Both, 116 | Colour = Color4.Black.Opacity(0.6f), 117 | }, 118 | romNameText = new ScrollingSpriteText 119 | { 120 | Margin = new MarginPadding { Horizontal = 5 }, 121 | Font = OsuFont.GetFont(Typeface.Torus, 28, FontWeight.Bold), 122 | Anchor = Anchor.Centre, 123 | Origin = Anchor.Centre, 124 | Text = romName.Replace(RomStore.RecognizedExtensions.Where(ext => romName.Contains(ext)).First(), "") 125 | }, 126 | } 127 | } 128 | } 129 | } 130 | } 131 | }; 132 | } 133 | 134 | [BackgroundDependencyLoader] 135 | private void load(TextureStore textures) 136 | { 137 | cartridge.Texture = textures?.Get("Textures/cartridge"); 138 | } 139 | 140 | public void MarkUnavailable() 141 | { 142 | loadFailedIcon 143 | .FadeIn(250, Easing.In) 144 | .Then(800) 145 | .FadeOut(400, Easing.Out); 146 | 147 | loadFailedText 148 | .FadeIn(250, Easing.In) 149 | .Then(800) 150 | .FadeOut(400, Easing.Out); 151 | 152 | romNameText 153 | .FadeColour(Color4.Red, 250, Easing.In) 154 | .Then(800) 155 | .FadeColour(Color4.White, 400, Easing.Out); 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Utils/StartupTaskAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | public sealed class StartupTaskAttribute : Attribute 5 | { 6 | /// 7 | /// The priority of this task. Tasks with lower values will be run first. 8 | /// 9 | public int Priority { get; set; } = 0; 10 | 11 | public StartupTaskAttribute() 12 | { 13 | } 14 | } -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Utils/StartupTaskQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Threading; 6 | using osu.Framework.Logging; 7 | using LogLevel = osu.Framework.Logging.LogLevel; 8 | 9 | namespace osu.Game.Rulesets.Gamebosu.Utils 10 | { 11 | /// 12 | /// Utility class for registering ruleset initialization tasks during game startup. 13 | /// 14 | internal static class StartupTaskQueue 15 | { 16 | // used for tracking whether the game has already completed startup. 17 | private static volatile bool gameFinishedStartup; 18 | private static volatile int numInstances; 19 | 20 | static StartupTaskQueue() 21 | { 22 | numInstances = 0; 23 | gameFinishedStartup = false; 24 | } 25 | 26 | /// 27 | /// Runs the startup tasks with a 28 | /// 29 | public static void RunStartupTasks(OsuGame game, GamebosuRuleset ruleset) 30 | { 31 | if (!gameFinishedStartup) 32 | { 33 | var startup_tasks = Assembly 34 | .GetExecutingAssembly() 35 | .GetTypes() 36 | .Where(type => type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public) 37 | .Any(method => method.GetCustomAttributes(typeof(StartupTaskAttribute), false).Any())) 38 | .SelectMany(type => type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).Where(method => method.GetCustomAttributes(typeof(StartupTaskAttribute), false).Any())) 39 | .OrderBy(method => (method.GetCustomAttributes(typeof(StartupTaskAttribute), false).First() as StartupTaskAttribute).Priority) 40 | .AsEnumerable(); 41 | 42 | foreach (var task in startup_tasks) 43 | { 44 | try 45 | { 46 | task.Invoke(null, new object[] { game, ruleset }); 47 | } 48 | catch (Exception e) 49 | { 50 | Logger.Log($"Failed to run startup task {task.DeclaringType.Name}:{task.Name} --> {e}", LoggingTarget.Runtime, LogLevel.Important); 51 | } 52 | } 53 | 54 | gameFinishedStartup = true; 55 | } 56 | 57 | Interlocked.Increment(ref numInstances); 58 | } 59 | 60 | public static void FreeInstance() 61 | { 62 | Interlocked.Decrement(ref numInstances); 63 | 64 | if (numInstances == 0) 65 | gameFinishedStartup = false; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/Utils/UIInjectionHooks.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using osu.Framework.Graphics.Containers; 3 | using osu.Game.Overlays.Toolbar; 4 | using osu.Game.Rulesets.Gamebosu.Graphics; 5 | 6 | namespace osu.Game.Rulesets.Gamebosu.Utils 7 | { 8 | internal static class UIInjectionHook 9 | { 10 | /// 11 | /// Inject a clickable icon into the game toolbar. 12 | /// 13 | [StartupTask(Priority = int.MaxValue)] 14 | public static void InjectToolbarIcon(OsuGame game, GamebosuRuleset ruleset) 15 | { 16 | // we're hooking the toolbar load 17 | game.Toolbar.OnLoadComplete += _ => 18 | { 19 | var userToolbarButton = typeof(Toolbar) 20 | .GetField("userButton", BindingFlags.Instance | BindingFlags.NonPublic)? 21 | .GetValue(game.Toolbar) as ToolbarUserButton; 22 | 23 | if (userToolbarButton?.Parent is FillFlowContainer flow) 24 | flow.Insert(-1, new GamebosuToolbarIcon(ruleset)); 25 | }; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /osu.Game.Rulesets.Gamebosu/osu.Game.Rulesets.Gamebosu.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | osu.Game.Rulesets.Gamebosu 5 | Library 6 | 0.0.0 7 | osu.Game.Rulesets.Gamebosu 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | --------------------------------------------------------------------------------