mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Compare commits
219 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18f2f18e41 | |||
| ec3c6ce26e | |||
| 9862dfa78d | |||
| e3f91ea593 | |||
| 509b2cd9b9 | |||
| 1b54d86324 | |||
| 425b2ecdb1 | |||
| 3b973e1597 | |||
| 86d2781e67 | |||
| 5d10f139a9 | |||
| 9b5a1711ce | |||
| 646ec820a5 | |||
| a144a308f6 | |||
| 07818cf8f2 | |||
| ccbcc8296d | |||
| bea435439e | |||
| d9ff78c21d | |||
| 14a4bf3408 | |||
| 172d7e4578 | |||
| 5986cf7a15 | |||
| a5e4b745ef | |||
| 4cd538fe21 | |||
| c406dfee79 | |||
| 8a168d20b3 | |||
| b16f7150e8 | |||
| c4319f1c6c | |||
| d9003fa07b | |||
| eb2235e017 | |||
| 1e784c243b | |||
| 23e9b52af2 | |||
| e42ac4eca3 | |||
| 622595a7a0 | |||
| 556ca1b1e6 | |||
| cef4f22305 | |||
| ee1dd7b21f | |||
| 487b73a859 | |||
| a56fdde0e7 | |||
| 99f91d25c3 | |||
| 8579b0697d | |||
| f0761c8359 | |||
| b1833721d0 | |||
| aba099e15a | |||
| d25c0cced5 | |||
| bc4f6304db | |||
| 4357454b14 | |||
| 528abbcaa3 | |||
| 9bcc605e00 | |||
| f7e3b9ae9d | |||
| 1b963a99c1 | |||
| 363cc3cc5e | |||
| 8307a975ea | |||
| f5ecdfca60 | |||
| 5bb92d804b | |||
| 5b4b962015 | |||
| b43cfdd70b | |||
| 77350a823e | |||
| 5844aea281 | |||
| 8af5d8c3e4 | |||
| f0f3721ec5 | |||
| 5641c25cc1 | |||
| c1b32c2fc3 | |||
| dc70d2889f | |||
| 6b2879d9dc | |||
| 19e842d721 | |||
| 8d28c3cfc8 | |||
| baec206bf3 | |||
| 3aacd7575b | |||
| d739245e70 | |||
| c88d93b0ab | |||
| 64280509b0 | |||
| a7e81cfa8a | |||
| 2620354888 | |||
| 61a8790448 | |||
| 5b4af58baa | |||
| 6cd3c65362 | |||
| 211a3b9a39 | |||
| a4fd92a014 | |||
| 295d0f90ba | |||
| 5592242963 | |||
| 0212f3ba26 | |||
| 36521a2b1b | |||
| 571a4f23ea | |||
| 2b9829d57a | |||
| 2f6ea39f79 | |||
| 8e33214fd0 | |||
| 310dfb94c2 | |||
| 39e2a54e1e | |||
| 829cace7b9 | |||
| e82afa7e22 | |||
| 5e64ce16f4 | |||
| 2154d90759 | |||
| d889c85b4a | |||
| cc4d033db2 | |||
| 1cfef9f607 | |||
| bbd26d1c12 | |||
| 72f0c22e88 | |||
| 72daaeee0e | |||
| 26765c45c7 | |||
| 2afcaa46f9 | |||
| 3c5b2a2eed | |||
| 0ff8e865aa | |||
| 2d60acce51 | |||
| 53fb197585 | |||
| 3c11f5a0a1 | |||
| bef27b4ac5 | |||
| 0d0cfa1b4e | |||
| 286f4aa68d | |||
| 58f563ed61 | |||
| 523575e43c | |||
| 414017930e | |||
| 01550557fb | |||
| cdfb957203 | |||
| c647099f60 | |||
| 8899017a37 | |||
| c8b983fd76 | |||
| 24ad6b6a1d | |||
| ee9e23ef2c | |||
| 3125009e80 | |||
| b23e211e11 | |||
| 2cc9b342b7 | |||
| 085a74a6b3 | |||
| f6159a863c | |||
| 4430138e77 | |||
| 04eca2cbc0 | |||
| c8d47f8e67 | |||
| f7da6fdb63 | |||
| 2466bb6d4c | |||
| 5f293e38b6 | |||
| 08ce0b1da3 | |||
| e12aa7e695 | |||
| c92a32a503 | |||
| 56fdfdca49 | |||
| b2510645e5 | |||
| b5a08584a0 | |||
| 78568cd235 | |||
| 8e86d4a7c5 | |||
| 6322ff2dd5 | |||
| 89c3b93ba6 | |||
| 580dea6b44 | |||
| b203adc66f | |||
| 7a2639f772 | |||
| 535430d0c5 | |||
| a0c9c88e0e | |||
| 4b7610f39f | |||
| a06e903c5c | |||
| f79f46269f | |||
| b82ddc1c59 | |||
| f4dc6ab838 | |||
| 62dde63206 | |||
| 5c034013fe | |||
| 23717c15d1 | |||
| 09acc3ccaa | |||
| 7c3f4f6a64 | |||
| 8dc48b20cb | |||
| 165b17e034 | |||
| 4255e2ad85 | |||
| 16b7c1ed76 | |||
| d179bde348 | |||
| e2234b19ea | |||
| 45259f304b | |||
| 220c7940a8 | |||
| 9665dbcb4e | |||
| 423a17070c | |||
| 8d88b59e3d | |||
| ae9d1dfc9b | |||
| 6930df940f | |||
| fd523f4017 | |||
| 4c8f903256 | |||
| d2ba6aadc1 | |||
| 0023066e32 | |||
| 39bcf63e3c | |||
| 656f32e755 | |||
| f66279980b | |||
| 1f65841e62 | |||
| 0422e7fee8 | |||
| 7fdf165d57 | |||
| 31d1b8536d | |||
| 20ac0ef7da | |||
| a72c849693 | |||
| 48f3bf53ca | |||
| e78a1189b0 | |||
| 1209d8e32a | |||
| b89da81989 | |||
| b0a5cbc74e | |||
| a6d8bedde2 | |||
| e9824e86f4 | |||
| 220837d2fb | |||
| 1bfdcb732a | |||
| 9865f91b6d | |||
| 838b1b3b93 | |||
| 0f7a30992d | |||
| 1c2c997b6b | |||
| bbbaeb86d0 | |||
| 34921b166e | |||
| f9b10a1174 | |||
| 6b20fa8f7b | |||
| bc5fb017cf | |||
| ce82f53568 | |||
| 4f5ef38d1b | |||
| 26e2ed5bbf | |||
| a5d42f3687 | |||
| 811e49327a | |||
| a8bb34c2d8 | |||
| 13b426eca6 | |||
| dceb09ec36 | |||
| e89199fec3 | |||
| 1b2136ffb9 | |||
| 416cf41841 | |||
| 3940a0a06c | |||
| 6a987126c8 | |||
| a4f68ebc8b | |||
| b7adfacfd1 | |||
| ee03a90f02 | |||
| 383d917e25 | |||
| e15d4c45d4 | |||
| 6077e51203 | |||
| 079dc32429 | |||
| 01ef77832d | |||
| d29e6d39f5 |
+1
-1
@@ -1 +1 @@
|
||||
custom: https://mee6.gg/m/bsmanager
|
||||
|
||||
|
||||
@@ -1,76 +1,243 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/Zagrios/bs-manager">
|
||||
<img src="https://raw.githubusercontent.com/Zagrios/bs-manager/master/resources/readme/icon.svg" alt="logo" width="250px"/>
|
||||
</a>
|
||||
<h3 align="center">BSManager</h3>
|
||||
<p align="center">Simple and fancy tools that alow you to download, launch and manage BeatSaber versions, Maps and Mods easily and quickly.</p>
|
||||
</p>
|
||||
<a name="readme-top"></a>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/Zagrios/bs-manager/blob/master/resources/readme/beat-running.png?raw=true" width="130"/>
|
||||
</p>
|
||||
<!-- PROJECT SHIELDS -->
|
||||
<!--
|
||||
*** I'm using markdown "reference style" links for readability.
|
||||
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
|
||||
*** See the bottom of this document for the declaration of the reference variables
|
||||
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
|
||||
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
|
||||
-->
|
||||
|
||||
<details open="open">
|
||||
<summary>
|
||||
<h2>Table of Contents</h2>
|
||||
</summary>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#about-the-project">About The Project</a>
|
||||
<ul><li><a href="#built-with">Built With</a></li></ul>
|
||||
</li>
|
||||
<li><a href="#how-to-use">How To Use</a></li>
|
||||
<li><a href="#having-problems">Having problems?</a></li>
|
||||
<li><a href="#acknowledgements">Acknowledgements</a></li>
|
||||
</ol>
|
||||
</details>
|
||||
|
||||
<h2 id="about-the-project">About The Project</h2>
|
||||
<p>
|
||||
Have you ever wanted to switch between multiple BeatSaber version? To have a specific version for you and your friends, or for personal use and Streaming use? Have you ever wanted to manage easily <b>Maps</b> and <b>Mods</b> between versions? All of that in one place? <b>Then this program is made for you!</b>
|
||||
<br/><br/>
|
||||
BSManager is designed to download any BeatSaber version from Steam's depots, and launch it within the same program!<br>
|
||||
- You can install as many versions as you want, customize them to quickly differentiate them, clone them to separate the additional contents of the same version!<br>
|
||||
- You can clone and launch your Steam version from the program!<br/><br/>
|
||||
<b>In the near future</b><br/>
|
||||
- You can Create a master Maps folder and link it across all versions!<br/>
|
||||
- You can download Maps with "OneClick"!<br/>
|
||||
- You can download Maps from BSManager!<br/>
|
||||
- You can download and manage Mods for each versions!<br/>
|
||||
- And even more!
|
||||
</p>
|
||||
<h3 id="built-with">Built With</h3>
|
||||
<!-- TITLE -->
|
||||
<div align="center">
|
||||
<a href="https://github.com/Zagrios/bs-manager">
|
||||
<img src="resources/readme/icon.svg" alt="Logo" width="250" height="250">
|
||||
</a>
|
||||
<br><br>
|
||||
<h2><b>BSManager</b></h2>
|
||||
<i>(Beat Saber Manager)</i>
|
||||
<br><br>
|
||||
<span>
|
||||
Download, manage and customize your versions of Beat Saber with a simple click!
|
||||
</span>
|
||||
<br>
|
||||
<span>
|
||||
<a href="https://github.com/Zagrios/bs-manager/issues/new?assignees=Zagrios&labels=bug&template=-bug--bug-report.md&title=%5BBUG%5D+%3A+">Report Bug</a>
|
||||
·
|
||||
<a href="https://github.com/Zagrios/bs-manager/issues/new?assignees=Zagrios&labels=enhancement&template=-feat---feature-request.md&title=%5BFEAT.%5D+%3A+">Request Feature</a>
|
||||
·
|
||||
<a href="https://github.com/Zagrios/bs-manager/security/policy">Report a security vulnerability</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- BADGES -->
|
||||
---
|
||||
<br>
|
||||
<div align="center" >
|
||||
<a href="https://github.com/Zagrios/bs-manager/stargazers"><img src ="https://img.shields.io/github/stars/Zagrios/bs-manager?style=for-the-badge" alt="Stargazers"/></a>
|
||||
<a href="https://github.com/Zagrios/bs-manager/network/members"><img src ="https://img.shields.io/github/forks/Zagrios/bs-manager?style=for-the-badge" alt="Forks"/></a>
|
||||
<a href="https://github.com/Zagrios/bs-manager/blob/master/LICENSE"><img src ="https://img.shields.io/github/license/Zagrios/bs-manager?style=for-the-badge" alt="License"/></a>
|
||||
<a href="https://github.com/Zagrios/bs-manager/graphs/contributors"><img src ="https://img.shields.io/github/contributors/Zagrios/bs-manager?style=for-the-badge" alt="Contributors"/></a>
|
||||
<a href="https://github.com/Zagrios/bs-manager/issues"><img alt="GitHub issues" src="https://img.shields.io/github/issues/Zagrios/bs-manager?style=for-the-badge"></a>
|
||||
<br>
|
||||
<a href="https://discord.gg/uSqbHVpKdV"><img src ="https://img.shields.io/badge/-DISCORD-5865f2?style=for-the-badge&logo=discord&logoColor=ffffff" alt="discord"/></a>
|
||||
<!--<a href="https://mee6.xyz/fr/m/bsmanager"><img src ="https://img.shields.io/badge/-🥰%20Support%20BSM-EC4546?style=for-the-badge" alt="Donation"/></a>-->
|
||||
<a href="https://twitter.com/BSManager_"><img src ="https://img.shields.io/badge/-Twitter-F5F8FA?style=for-the-badge&logo=Twitter" alt="Twitter"/></a>
|
||||
<br>
|
||||
[<a href="#readme-bot">Go to bottom</a>]
|
||||
</div>
|
||||
|
||||
---
|
||||
<!-- TABLE OF CONTENTS -->
|
||||
<b>Table of Contents</b>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/electron-react-boilerplate/electron-react-boilerplate">Electron React Boilerplate</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/SteamRE/DepotDownloader">DepotDownloader</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#about-the-project">About The Project</a>
|
||||
<ul>
|
||||
<li><a href="#built-with">Built With</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#usage">Usage</a></li>
|
||||
<ul>
|
||||
<li><a href="#how-to-install">How to install?</a></li>
|
||||
<li><a href="#manage-versions">Manage Versions</a></li>
|
||||
<li><a href="#customize-your-versions">Customize your versions</a></li>
|
||||
<li><a href="#install-mods">Install Mods</a></li>
|
||||
<li><a href="#install-maps">Install Maps</a></li>
|
||||
<li><a href="#one-click">One Click</a></li>
|
||||
<li><a href="#having-problems">Having problems?</a></li>
|
||||
</ul>
|
||||
<li><a href="#credits">Credits</a></li>
|
||||
<li><a href="#contributing">Contributing</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="how-to-use">How To Use</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Download the latest release from <a href="https://github.com/Zagrios/bs-manager/releases">Releases</a>.
|
||||
</li>
|
||||
<li>Execute the installer and BSManager will start itself.</li>
|
||||
<li>Once its done if you want to download a version, select a version and download it!</li>
|
||||
<li>From the version page you can choose launch options, launch the version, and more from the dropdown menu!</li>
|
||||
</ul>
|
||||
<!-- ABOUT THE PROJECT -->
|
||||
<div align="center">
|
||||
<h1> </h1>
|
||||
<h1><b>About The Project</b></h1>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://github.com/Zagrios/bs-manager">BSManager</a> was created to unify and improve the two most used Apps in the community (<a href="https://github.com/RiskiVR/BSLegacyLauncher">BS legacy launcher</a> and <a href="https://github.com/Assistant/ModAssistant">Mod Assistant</a>).
|
||||
<br><br>
|
||||
<h4><a href="https://github.com/Zagrios/bs-manager">BSManager</a> will allow you to:</h4>
|
||||
<ul>
|
||||
<li><b>Manage multiple BeatSaber versions</b>, designed for people who need to play on different versions or have multiple profiles for the same version.</li>
|
||||
<li><b>Download your maps in the same way</b>, in addition to that, depending on your choice, maps are not version dependent. so you will be able to find your maps whatever version you are using without having to transfer them.</li>
|
||||
<li><b>Install your mods in one click</b>, just like <a href="https://github.com/Assistant/ModAssistant">Mod Assistant</a>, <a href="https://github.com/Zagrios/bs-manager">BSManager</a> will allow you to install your mods quickly and securely depending on the version you choose.</li>
|
||||
<li><b>Customize your interface</b>, we know that some of you like to customize your interfaces to the maximum. That's why <a href="https://github.com/Zagrios/bs-manager">BSManager</a> brings you peace of mind on this point, you can change the name of the versions, their color, and you can even change the color of the logo! Of course, a dark theme has been added to protect your eyes at night.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
<img src="resources/readme/preview.png" alt="preview">
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<h2 id="having-problems">Having problems?</h2>
|
||||
<p>
|
||||
See the <a href="https://github.com/Zagrios/bs-manager/issues">open issues</a> for a list of known issues, from there you can create a new issue for the problem you have!
|
||||
Otherwise you can add on to existing issues if one matches what you're encountering.
|
||||
</p>
|
||||
<h2 id="acknowledgements">Acknowledgement</h2>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Zagrios">Zagrios</a> - Founder, Lead Developer & Project Lead</li>
|
||||
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Custom DepotDownloader Developer</li>
|
||||
<li><a href="https://github.com/GaetanGrd">Gaëtan Gerard</a> - Main Alpha Tester</li>
|
||||
</ul>
|
||||
<p align="center">
|
||||
<img src="https://github.com/Zagrios/bs-manager/blob/master/resources/readme/beat-conflict.png?raw=true" width="130"/>
|
||||
</p>
|
||||
<!--BUILT WITH-->
|
||||
<div>
|
||||
<h2><b>Built With</b></h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://electron-react-boilerplate.js.org/"><img src="https://img.shields.io/badge/-Electron%20React%20Boilerplate-black?style=for-the-badge&logo=Electron" alt="Electron React Boilerplate"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/SteamRE/DepotDownloader"><img src="https://img.shields.io/badge/-Depot%20Downloader-2a475e?style=for-the-badge&logo=steam" alt="Depot Downloader"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://rxjs.dev/"><img src="https://img.shields.io/badge/-RxJs-purple?style=for-the-badge&logo=ReactiveX" alt="RxJs"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://tailwindcss.com/"><img src="https://img.shields.io/badge/-Tailwind%20CSS-white?style=for-the-badge&logo=Tailwind%20CSS" alt="TailWind CSS"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!--USAGE-->
|
||||
<div align="center">
|
||||
<h1> </h1>
|
||||
<h1><b>Usage</b></h1>
|
||||
</div>
|
||||
|
||||
<!--HOW TO INSTALL?-->
|
||||
<div>
|
||||
<h2><b>How to install?</b></h2>
|
||||
<ul>
|
||||
<li>Download the <a href="https://github.com/Zagrios/bs-manager/releases/latest">latest release</a> from <a href="https://github.com/Zagrios/bs-manager/releases">Releases</a>.</li>
|
||||
<li>Execute the installer and <a href="../..">BSManager</a> will start itself.</li>
|
||||
<li>Once its done if you want to download a version, select a version and download it! </li>
|
||||
<li>From the version page you can choose options, launch the version, and more!</li>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!--MANAGE VERSIONS-->
|
||||
<div>
|
||||
<h2><b>Manage Versions</b></h2>
|
||||
<span>
|
||||
<a href="https://github.com/Zagrios/bs-manager">BSManager</a> allows you to manage your versions of Beat Saber. It gives you the ability to download any version of Beat Saber as long as you have a Steam account that already owns the game. Using <a href="https://github.com/Zagrios/bs-manager">BSManager</a>, you can easily manage and update your collection of Beat Saber versions.
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
|
||||
https://user-images.githubusercontent.com/40648115/213008824-25cfdda3-6350-42dc-aa53-2132b4b8e838.mov
|
||||
</div>
|
||||
|
||||
<!--CUSTOM UR VERSIONS-->
|
||||
<div>
|
||||
<h2><b>Customize your versions</b></h2>
|
||||
<span>
|
||||
<a href="https://github.com/Zagrios/bs-manager">BSManager</a> will allow you to completely customize each of your downloaded versions, you can change the color of the icon, choose a name for the version and finally install your mods,maps and other contents according to the Beat Saber version!
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
|
||||
https://user-images.githubusercontent.com/40648115/213296794-74a1e20b-12dc-44ec-a67f-e25d7010bd3d.mov
|
||||
</div>
|
||||
|
||||
<!--INSTALL MODS-->
|
||||
<div>
|
||||
<h2><b>Install Mods</b></h2>
|
||||
<span>
|
||||
<a href="https://github.com/Zagrios/bs-manager">BSManager</a> allows you to manage Beat Saber mods in a quick and easy way. It uses the <a href="https://beatmods.com/#/">BeatMod API</a> to allow you to install, update or uninstall mods for each version of your collection. So the app can help you manage them efficiently.
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
|
||||
https://user-images.githubusercontent.com/40648115/213296816-bdaafc90-da76-4835-8d83-9ac6a4e1c549.mov
|
||||
</div>
|
||||
|
||||
<!--INSTALL MAPS-->
|
||||
<div>
|
||||
<h2><b>Install Maps</b></h2>
|
||||
<span>
|
||||
In addition to managing mods, <a href="https://github.com/Zagrios/bs-manager">BSManager</a> allows you to manage and organize custom beatmaps existing on <a href="https://beatsaver.com">Beat Saver</a>, a popular site for sharing custom beatmaps for beat Saber. Moreover the app allow you to share your maps across all your versions.
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
|
||||
https://user-images.githubusercontent.com/40648115/213296838-f775fe83-866d-4764-a7d0-648dbb8ec983.mov
|
||||
</div>
|
||||
|
||||
<!--ONE CLICK-->
|
||||
<div>
|
||||
<h2><b>One Click</b></h2>
|
||||
<span>
|
||||
The "One-Click" feature of <a href="https://github.com/Zagrios/bs-manager">BSManager</a> is an incredibly convenient feature for Beat Saber users. It allows easy and quick installation of models, maps and playlists for all versions of Beat Saber you own.
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div align="center">
|
||||
|
||||
https://user-images.githubusercontent.com/40648115/213435051-7feb815d-f32b-4135-b095-ef49726a836c.mov
|
||||
</div>
|
||||
|
||||
<!--HAVING PROBLEMS?-->
|
||||
<div>
|
||||
<h2><b>Having problems?</b></h2>
|
||||
<span>
|
||||
See the <a href="https://github.com/Zagrios/bs-manager/issues">open issues</a> to show the list of known issues, from there you can create a new issue for your problem!
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<!-- Credits -->
|
||||
<div>
|
||||
<h1><b>Credits</b></h1>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Zagrios">Zagrios</a> - Founder & Lead Developer</li>
|
||||
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Project Team & Developpement help</li>
|
||||
<li><a href="https://github.com/GaetanGrd">GaetanGrd</a> - Project Team & Developpement help</li>
|
||||
<li><a href="https://github.com/cheddZy">cheddZy</a> - Icon creator</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Contributing -->
|
||||
<br>
|
||||
<!--CONTRIBUTING-->
|
||||
<div>
|
||||
<h1><b>Contributing</b></h1>
|
||||
<p>
|
||||
If you'd like to contribute, check out the <a href="https://github.com/Zagrios/bs-manager/blob/master/CONTRIBUTING.md">contributing guide</a>
|
||||
</p>
|
||||
<p>Thank you to all the people who already contributed to BSManager!</p>
|
||||
<div>
|
||||
<a href="https://github.com/Zagrios/bs-manager/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=Zagrios/bs-manager" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div align="right">
|
||||
[<a href="#readme-top">Return to top</a>]
|
||||
</div>
|
||||
|
||||
<h1> </h1>
|
||||
<a name="readme-bot"></a>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
If you discover a security issue in BSManager, please report it by sending an
|
||||
email to [contact@bsmanager.io](mailto:contact@bsmanager.io).
|
||||
|
||||
This will allow us to assess the risk, and make a fix available before we add a
|
||||
bug report to the GitHub repository.
|
||||
|
||||
Thanks for helping make BSManager safe for everyone.
|
||||
@@ -509,5 +509,13 @@
|
||||
"ReleaseImg": "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans//32055887/d9ed8771498be7fc83721aaaaa5b15a08fbeadb1.png",
|
||||
"ReleaseDate": "1670943003",
|
||||
"year": "2022"
|
||||
},
|
||||
{
|
||||
"BSVersion": "1.28.0",
|
||||
"BSManifest": "7463243155526905423",
|
||||
"ReleaseURL": "https://steamcommunity.com/games/620980/announcements/detail/3666530358620442392",
|
||||
"ReleaseImg": "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans//32055887/8f978bbf292810004bca12523e76be8a7eec8c4e.png",
|
||||
"ReleaseDate": "1677593822",
|
||||
"year": "2023"
|
||||
}
|
||||
]
|
||||
@@ -13,14 +13,29 @@
|
||||
"refuse": "Refuse",
|
||||
"apply": "Apply"
|
||||
},
|
||||
"nav-bar":{
|
||||
"add-version": "Add a version",
|
||||
"settings": "Settings"
|
||||
},
|
||||
"pages": {
|
||||
"shared-maps":{
|
||||
"title": "Shared maps"
|
||||
},
|
||||
"version-viewer": {
|
||||
"launch-mods": {
|
||||
"oculus": "Oculus Mod",
|
||||
"desktop": "Desktop Mod",
|
||||
"debug": "Debug Mod"
|
||||
"oculus": "Oculus Mode",
|
||||
"oculus-description": "If you are using Beat Saber via Steam, it allows you to use Oculus's VR composer without passing by SteamVR, to gain performances This is not necessary for using Oculus headsets.",
|
||||
"desktop": "Desktop Mode",
|
||||
"desktop-description": "This allows you to use WASD and the mouse to navigate around the menu in game. This makes testing much easier, because you don't have to put on your headset!",
|
||||
"debug": "Debug Mode",
|
||||
"debug-description": "Enables the output log window for IPA. This will show the debug console that mods use.",
|
||||
"advanced-launch": {
|
||||
"button": "Advanced launch",
|
||||
"placeholder": "Additional arguments ex: --revert; --nowait"
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
"title": "Shared maps",
|
||||
"search-bar": {
|
||||
"search-placeholder": "Search a map",
|
||||
"filters-btn": "Filters",
|
||||
@@ -38,7 +53,7 @@
|
||||
"link-maps": {
|
||||
"tooltips": {
|
||||
"link": "Link maps",
|
||||
"unlink": "Unling maps"
|
||||
"unlink": "Unlink maps"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -51,6 +66,7 @@
|
||||
},
|
||||
"mods": {
|
||||
"loading-mods": "Loading mods...",
|
||||
"no-internet": "No internet",
|
||||
"buttons": {
|
||||
"more-infos": "More info",
|
||||
"install-or-update": "Install or update"
|
||||
@@ -72,12 +88,17 @@
|
||||
"verify-files": "Verify files",
|
||||
"clone": "Clone",
|
||||
"edit": "Edit",
|
||||
"uninstall": "Uninstall"
|
||||
"uninstall": "Uninstall",
|
||||
"shared-folders": "Shared Folders"
|
||||
}
|
||||
},
|
||||
"available-versions": {
|
||||
"title": "Select a version",
|
||||
"steam-release": "Release page"
|
||||
"steam-release": "Release page",
|
||||
"dropdown": {
|
||||
"refresh": "Refresh list",
|
||||
"import-version" :"Import a version"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"steam": {
|
||||
@@ -164,10 +185,12 @@
|
||||
"shared": {
|
||||
"errors": {
|
||||
"titles": {
|
||||
"operation-running": "Operation running"
|
||||
"operation-running": "Operation running",
|
||||
"no-internet": "No internet"
|
||||
},
|
||||
"msg": {
|
||||
"operation-running": "Wait for the end of the current operation then start again."
|
||||
"operation-running": "Wait for the end of the current operation then start again.",
|
||||
"no-internet": "Check your connection and try again."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -223,6 +246,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bs-import-version":{
|
||||
"success":{
|
||||
"start-import": {
|
||||
"title": "Import in progress 👌",
|
||||
"desc": "The import may take several minutes depending on your configuration."
|
||||
},
|
||||
"imported": {
|
||||
"title": "Imported version 🎉"
|
||||
}
|
||||
},
|
||||
"errors":{
|
||||
"import-error":{
|
||||
"desc": "Check that the selected folder is a BeatSaber installation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"move-folder": {
|
||||
"success": {
|
||||
@@ -380,6 +419,14 @@
|
||||
"success":"Model installation complete",
|
||||
"error":"An error occurred while installing the model"
|
||||
}
|
||||
},
|
||||
"shared-folder": {
|
||||
"info": {
|
||||
"userdata-backup-created":{
|
||||
"title": "Backup created",
|
||||
"msg": "Sharing the 'UserData' folder can generate errors, in case of problems unlink the folder to restore the backup"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"modals": {
|
||||
@@ -413,10 +460,23 @@
|
||||
"label": "Stay connected"
|
||||
}
|
||||
},
|
||||
"why-credentials": "Why do you need my credentials ?",
|
||||
"buttons": {
|
||||
"submit": "Login"
|
||||
}
|
||||
},
|
||||
"steam-credentials":{
|
||||
"title": "Steam Credentials",
|
||||
"p-1": "The credentials are only used to download the game because steam need to verify that you paid the game in order to be allowed to download it. They aren't saved and directly passed to DepotDownloader. If you don't want to enter your credentials you can follow this tutorial :",
|
||||
"p-2": "and then click on the gear icon in the top right corner and select \"Import a version\", select the folder where beat saber has been downloaded (If you follow the tutorial above you should have the correct location)"
|
||||
},
|
||||
"bs-import-version":{
|
||||
"title": "Import a version",
|
||||
"description": "Imports a version of BeatSaber to use with BSManager. The import will copy the selected BeatSaber installation folder to the BSManager versions folder.",
|
||||
"buttons":{
|
||||
"submit": "Import a version"
|
||||
}
|
||||
},
|
||||
"bs-uninstall": {
|
||||
"title": "Uninstall",
|
||||
"description": "Are you sure you want to uninstall BeatSaber {version} ? You will have to download it again to play it.",
|
||||
@@ -505,7 +565,9 @@
|
||||
},
|
||||
"download-maps": {
|
||||
"search-btn": "Search",
|
||||
"loading-maps": "Loading maps..."
|
||||
"loading-maps": "Loading maps...",
|
||||
"no-maps-found": "No maps found",
|
||||
"no-internet": "No internet"
|
||||
},
|
||||
"mods-disclaimer":{
|
||||
"title": "disclaimer",
|
||||
@@ -514,6 +576,15 @@
|
||||
"li-2": "Mods are subject to being broken by updates and that's normal - be patient and respectful when this happens, as modders are volunteers with real lives.",
|
||||
"li-3": "Beat Games aren't purposefully trying to break mods. They wish to work on the codebase and sometimes this breaks mods, but they are not out to kill mods.",
|
||||
"p-2": "Do not attack the game developers for issues related to mods, and vice versa - modders and game developers are two separate groups. Just don't be a jerk ok."
|
||||
},
|
||||
"shared-folders":{
|
||||
"title": "Shared Folders",
|
||||
"description": "Link BeatSaber folders to synchronize their contents with shared folders in other versions. Note that deleting content will also be shared.",
|
||||
"buttons": {
|
||||
"add-folder": "Add Folder",
|
||||
"link-folder": "Link Folder",
|
||||
"unlink-folder": "Unlink Folder"
|
||||
}
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
|
||||
@@ -13,12 +13,26 @@
|
||||
"refuse": "Rechazar",
|
||||
"apply": "Aplicar"
|
||||
},
|
||||
"nav-bar":{
|
||||
"add-version": "Agregar una versión",
|
||||
"settings": "Ajustes"
|
||||
},
|
||||
"pages": {
|
||||
"shared-maps":{
|
||||
"title": "Mapas comunes"
|
||||
},
|
||||
"version-viewer": {
|
||||
"launch-mods": {
|
||||
"oculus": "Oculus Mod",
|
||||
"oculus-description": "Si estás usando Beat Saber a través de Steam, te permite usar el compositor VR de Oculus sin pasar por SteamVR, para ganar prestaciones. Esto no es necesario para usar auriculares Oculus.",
|
||||
"desktop": "Desktop Mod",
|
||||
"debug": "Debug Mod"
|
||||
"desktop-description": "Esto te permite usar WASD y el mouse para navegar por el menú en juego. Esto hace que las pruebas sean mucho más fáciles, ¡porque no tienes que ponerte el auricular!",
|
||||
"debug": "Debug Mod",
|
||||
"debug-description": "Habilita la ventana de registro de salida para IPA. Esto mostrará la consola de depuración que usan los mods.",
|
||||
"advanced-launch": {
|
||||
"button": "Lanzamiento avanzado",
|
||||
"placeholder": "Argumentos adicionales ej: --revert; --no-wait"
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
"search-bar": {
|
||||
@@ -51,6 +65,7 @@
|
||||
},
|
||||
"mods": {
|
||||
"loading-mods": "Cargando mods...",
|
||||
"no-internet": "Sin internet",
|
||||
"buttons": {
|
||||
"more-infos": "Más información",
|
||||
"install-or-update": "Instalar o actualizar"
|
||||
@@ -72,12 +87,17 @@
|
||||
"verify-files": "Verificar los archivos",
|
||||
"clone": "Clonar",
|
||||
"edit": "Editar",
|
||||
"uninstall": "Desinstalar"
|
||||
"uninstall": "Desinstalar",
|
||||
"shared-folders": "Carpetas Compartidas"
|
||||
}
|
||||
},
|
||||
"available-versions": {
|
||||
"title": "Seleccione una versión",
|
||||
"steam-release": "Publicación Página"
|
||||
"steam-release": "Publicación Página",
|
||||
"dropdown": {
|
||||
"refresh": "Actualizar la lista",
|
||||
"import-version" :"Importar una versión"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"steam": {
|
||||
@@ -164,10 +184,12 @@
|
||||
"shared": {
|
||||
"errors": {
|
||||
"titles": {
|
||||
"operation-running": "Operación en curso"
|
||||
"operation-running": "Operación en curso",
|
||||
"no-internet": "Sin internet"
|
||||
},
|
||||
"msg": {
|
||||
"operation-running": "Espere a que termine la operación actual y vuelva a empezar."
|
||||
"operation-running": "Espere a que termine la operación actual y vuelva a empezar.",
|
||||
"no-internet": "Comprueba tu conexión a Internet e inténtalo de nuevo."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -223,6 +245,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bs-import-version":{
|
||||
"success":{
|
||||
"start-import": {
|
||||
"title": "Importación en curso 👌",
|
||||
"desc": "La importación puede tardar varios minutos dependiendo de su configuración."
|
||||
},
|
||||
"imported": {
|
||||
"title": "Versión importada 🎉"
|
||||
}
|
||||
},
|
||||
"errors":{
|
||||
"import-error":{
|
||||
"desc": "Compruebe que la carpeta seleccionada es una instalación de BeatSaber."
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"move-folder": {
|
||||
"success": {
|
||||
@@ -380,6 +418,14 @@
|
||||
"success":"Instalación del modelo completada",
|
||||
"error":"Se produjo un error durante la instalación del modelo"
|
||||
}
|
||||
},
|
||||
"shared-folder": {
|
||||
"info": {
|
||||
"userdata-backup-created":{
|
||||
"title": "Backup creado",
|
||||
"msg": "Compartir la carpeta 'UserData' puede generar errores, en caso de problemas desvincular la carpeta para restaurar la copia de seguridad"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"modals": {
|
||||
@@ -413,10 +459,23 @@
|
||||
"label": "Manténgase conectado"
|
||||
}
|
||||
},
|
||||
"why-credentials": "¿Por qué necesitas mis credenciales?",
|
||||
"buttons": {
|
||||
"submit": "Inicio de sesión"
|
||||
}
|
||||
},
|
||||
"steam-credentials":{
|
||||
"title": "Steam Credentials",
|
||||
"p-1": "Las credenciales sólo se utilizan para descargar el juego porque steam necesita verificar que has pagado el juego para que se te permita descargarlo. No se guardan y se pasan directamente a DepotDownloader. Si no quieres introducir tus credenciales puedes seguir este tutorial :",
|
||||
"p-2": "y, a continuación, haga clic en el icono de engranaje en la esquina superior derecha y seleccione \"Importar una versión\", seleccione la carpeta donde se ha descargado beat saber (Si usted sigue el tutorial anterior debe tener la ubicación correcta)"
|
||||
},
|
||||
"bs-import-version":{
|
||||
"title": "Importar una versión",
|
||||
"description": "Importa una versión de BeatSaber para usar con BSManager. La importación copiará la carpeta de instalación seleccionada de BeatSaber en la carpeta de versiones de BSManager.",
|
||||
"buttons":{
|
||||
"submit": "Importar una versión"
|
||||
}
|
||||
},
|
||||
"bs-uninstall": {
|
||||
"title": "Desinstalar",
|
||||
"description": "¿Estás seguro de que quieres desinstalar BeatSaber {version}? Tendrás que descargarlo de nuevo para poder jugar.",
|
||||
@@ -505,7 +564,9 @@
|
||||
},
|
||||
"download-maps": {
|
||||
"search-btn": "buscar",
|
||||
"loading-maps": "Cargando mapas..."
|
||||
"loading-maps": "Cargando mapas...",
|
||||
"no-maps-found": "No se encontraron mapas",
|
||||
"no-internet": "Sin internet"
|
||||
},
|
||||
"mods-disclaimer":{
|
||||
"title": "descargo de responsabilidad",
|
||||
@@ -514,6 +575,15 @@
|
||||
"li-2": "Es probable que los mods dejen de funcionar debido a las actualizaciones y eso es normal. Sé paciente y respetuoso cuando suceda esto, ya que los modders son voluntarios y tienen una vida.",
|
||||
"li-3": "Beat Games no está intencionalmente tratando de romper los mods. Quieren mejorar el juego base y a veces esto rompe los mods, pero no es su objetivo matar a los mods.",
|
||||
"p-2": "No ataques a los desarrolladores por problemas relacionados con los mods y viceversa. Los modders y los desarrolladores son dos grupos distintos. No seas tonto, ¿de acuerdo?"
|
||||
},
|
||||
"shared-folders":{
|
||||
"title": "Carpetas Compartidas",
|
||||
"description": "Enlace las carpetas de BeatSaber para sincronizar su contenido con las carpetas compartidas en otras versiones. Tenga en cuenta que la eliminación de contenido también se compartirá.",
|
||||
"buttons": {
|
||||
"add-folder": "Añadir Carpeta",
|
||||
"link-folder": "Enlazar Carpeta",
|
||||
"unlink-folder": "Desenlazar Carpeta"
|
||||
}
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
|
||||
@@ -13,12 +13,26 @@
|
||||
"refuse": "Refuser",
|
||||
"apply": "Appliquer"
|
||||
},
|
||||
"nav-bar":{
|
||||
"add-version": "Ajouter une version",
|
||||
"settings": "Paramètres"
|
||||
},
|
||||
"pages": {
|
||||
"shared-maps":{
|
||||
"title": "Maps partagées"
|
||||
},
|
||||
"version-viewer": {
|
||||
"launch-mods": {
|
||||
"oculus": "Mode Oculus",
|
||||
"oculus-description": "Si vous utilisez Beat Saber via Steam, cela vous permet d'utiliser le compositeur VR d'Oculus sans passer par SteamVR, pour gagner en performances. Ceci n'est pas nécessaire pour utiliser les casques Oculus.",
|
||||
"desktop": "Mode Bureau",
|
||||
"debug": "Mode Debug"
|
||||
"desktop-description": "Cela vous permet d'utiliser WASD et la souris pour naviguer dans le menu en jeu. Cela rend les tests beaucoup plus faciles, car vous n'avez pas à mettre votre casque!",
|
||||
"debug": "Mode Debug",
|
||||
"debug-description": "Active la fenêtre de log pour IPA. Cela affichera la console de débogage utilisée par les mods.",
|
||||
"advanced-launch": {
|
||||
"button": "Lancement avancé",
|
||||
"placeholder": "Arguments supplémentaires ex: --revert; --nowait"
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
"search-bar": {
|
||||
@@ -51,6 +65,7 @@
|
||||
},
|
||||
"mods": {
|
||||
"loading-mods": "Chargement des mods...",
|
||||
"no-internet": "Pas d'internet",
|
||||
"buttons": {
|
||||
"more-infos": "Plus d'infos",
|
||||
"install-or-update": "Installer ou mettre à jour"
|
||||
@@ -72,12 +87,17 @@
|
||||
"verify-files": "Vérifier les fichiers",
|
||||
"clone": "Cloner",
|
||||
"edit": "Editer",
|
||||
"uninstall": "Désinstaller"
|
||||
"uninstall": "Désinstaller",
|
||||
"shared-folders": "Dossiers Partagés"
|
||||
}
|
||||
},
|
||||
"available-versions": {
|
||||
"title": "Choisi une version",
|
||||
"steam-release": "Notes de version"
|
||||
"title": "Choisis une version",
|
||||
"steam-release": "Notes de version",
|
||||
"dropdown": {
|
||||
"refresh": "Rafraichir la liste",
|
||||
"import-version" :"Importer une version"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"steam": {
|
||||
@@ -87,7 +107,7 @@
|
||||
},
|
||||
"appearance": {
|
||||
"title": "Apparence",
|
||||
"description": "Choisi les deux couleurs principales de BSManager.",
|
||||
"description": "Choisis les deux couleurs principales de BSManager.",
|
||||
"reset": "Réinitialiser",
|
||||
"sub-title": "Thème",
|
||||
"themes": {
|
||||
@@ -103,7 +123,7 @@
|
||||
},
|
||||
"additional-content": {
|
||||
"title": "Contenus additionnels",
|
||||
"description": "Les contenus additionnels te permet de personaliser BeatSaber !",
|
||||
"description": "Les contenus additionnels te permettent de personaliser Beat Saber!",
|
||||
"deep-links": {
|
||||
"sub-title": "Installations OneClick"
|
||||
}
|
||||
@@ -126,7 +146,7 @@
|
||||
},
|
||||
"patreon": {
|
||||
"title": "Soutenir BSManager 💖",
|
||||
"description": "Soutien le projet et aide-nous à fournir des améliorations continues à BSManager.",
|
||||
"description": "Soutiens le projet et aide-nous à fournir des améliorations continues à BSManager.",
|
||||
"buttons": {
|
||||
"support": "Soutenir BSManager 🥰",
|
||||
"supporters": "Supporteurs 👀"
|
||||
@@ -158,16 +178,18 @@
|
||||
},
|
||||
"common": {
|
||||
"msg": {
|
||||
"error-occurred": "Une erreur c'est produite"
|
||||
"error-occurred": "Une erreur s'est produite"
|
||||
}
|
||||
},
|
||||
"shared": {
|
||||
"errors": {
|
||||
"titles": {
|
||||
"operation-running": "Opération en cours"
|
||||
"operation-running": "Opération en cours",
|
||||
"no-internet": "Pas d'internet"
|
||||
},
|
||||
"msg": {
|
||||
"operation-running": "Attend la fin de l'opération en cours puis recommences."
|
||||
"operation-running": "Attends la fin de l'opération en cours puis recommence.",
|
||||
"no-internet": "Verifie ta connexion internet et recommence."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -180,11 +202,11 @@
|
||||
},
|
||||
"warnings": {
|
||||
"msg": {
|
||||
"ManifestChecksum": "Le manifest télécharger précédemment ne correspond pas au nouveau 🤔",
|
||||
"ManifestChecksum": "Le manifest téléchargé précédemment ne correspond pas au nouveau 🤔",
|
||||
"ConnectionTimeout": "Ta connexion internet semble instable 🥶",
|
||||
"ConnectionLost": "La connexion a été perdue, retentative...",
|
||||
"ConnectionError": "Impossible de se connecter à Steam, retentative...",
|
||||
"Unknown": "Quelque chose d'étrange c'est produit 🤔 Votre connexion est surement instable."
|
||||
"ConnectionLost": "La connexion a été perdue, nouvelle tentative...",
|
||||
"ConnectionError": "Impossible de se connecter à Steam, nouvelle tentative...",
|
||||
"Unknown": "Quelque chose d'étrange s'est produit 🤔 Votre connexion est surement instable."
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
@@ -192,37 +214,53 @@
|
||||
"dotnet-required": ".NET 6 Requis"
|
||||
},
|
||||
"msg": {
|
||||
"401": "Steam semble pas vouloir nous laisser télécharger BeatSaber 😢",
|
||||
"401": "Steam ne semble pas vouloir nous laisser télécharger Beat Saber 😢",
|
||||
"404": "Impossible de contacter les serveurs de Steam.",
|
||||
"Password": "Le mot de passe est invalide.",
|
||||
"InvalidCredentials": "Ton e-mail ou mot de passe est invalide 😴",
|
||||
"InvalidPassword": "Ton mot de passe est invalide 😕",
|
||||
"NoManifest": "Aucun manifest n'a été trouvé.",
|
||||
"DirectoryCreate": "Impossible d'installer les dossiers nécessaires.",
|
||||
"NotAvailableApp": "Tu essayes de télécharger BeatSaber alors que tu ne l'as pas ? 🤣",
|
||||
"DepotNotFound": "Impossible de télécharger BeatSaber 😥 réessaye plus tard 😕",
|
||||
"NotAvailableApp": "Tu essayes de télécharger Beat Saber alors que tu ne l'as pas ? 🤣",
|
||||
"DepotNotFound": "Impossible de télécharger Beat Saber 😥 réessaye plus tard 😕",
|
||||
"NotCompleted": "Le téléchargement n'a pas pu se terminer ¯\\_(ツ)_/¯",
|
||||
"InvalidManifest": "Impossible de télécharger BeatSaber 😥 réessaye plus tard 😕",
|
||||
"NoValidKey": "Impossible de télécharger BeatSaber 😥 réessaye plus tard 😕",
|
||||
"NoManifestCode": "Impossible de télécharger BeatSaber 😥 réessaye plus tard 😕",
|
||||
"Unknown": "Une erreur inconnue c'est produite ¯\\_(ツ)_/¯",
|
||||
"InvalidManifest": "Impossible de télécharger Beat Saber 😥 réessaye plus tard 😕",
|
||||
"NoValidKey": "Impossible de télécharger Beat Saber 😥 réessaye plus tard 😕",
|
||||
"NoManifestCode": "Impossible de télécharger Beat Saber 😥 réessaye plus tard 😕",
|
||||
"Unknown": "Une erreur inconnue s'est produite ¯\\_(ツ)_/¯",
|
||||
"NoServer": "Impossible de contacter les serveurs de Steam.",
|
||||
"NotAllowed": "Apparemment tu n'es pas autorisé à télécharger BeatSaber 🥱",
|
||||
"NotAllowed": "Apparemment tu n'es pas autorisé à télécharger Beat Saber 🥱",
|
||||
"ConnectionTimeout": "Impossible de se connecter à Steam 😕",
|
||||
"SteamLib": "Si tu à cette erreur, report le bug sur GitHub avec les logs stp.",
|
||||
"SteamLib": "Si tu as cette erreur, signale le bug sur GitHub avec les logs stp.",
|
||||
"ConnectionError": "Impossible de se connecter à Steam après 10 essais 🤯",
|
||||
"LicenceError": "Impossible d'obtenir la liste des licences.",
|
||||
"verification-failed": "La vérification a échoué, réessaye plus tard.",
|
||||
"RateLimitExceeded": "Tu as essayé trop de fois attend un peu et recommence plus tard.",
|
||||
"RateLimitExceeded": "Tu as essayé trop de fois attends un peu et recommence plus tard.",
|
||||
"AlreadyDownloading": "Un téléchargement est déjà en cours",
|
||||
"no-internet": "Pas de connexion internet.",
|
||||
"dotnet-required": ".NET 6 Runtime doit être installé pour pouvoir télécharger une version de BeatSaber. Télécharge-le en cliquant sur le bouton ci-dessous."
|
||||
"dotnet-required": ".NET 6 Runtime doit être installé pour pouvoir télécharger une version de Beat Saber. Télécharge-le en cliquant sur le bouton ci-dessous."
|
||||
},
|
||||
"actions":{
|
||||
"download-dotnet": "Télécharger .NET 6"
|
||||
}
|
||||
}
|
||||
},
|
||||
"bs-import-version":{
|
||||
"success":{
|
||||
"start-import": {
|
||||
"title": "Importation en cours 👌",
|
||||
"desc": "L'importation peut durer plusieurs minutes selon votre configuration."
|
||||
},
|
||||
"imported": {
|
||||
"title": "Version importée 🎉"
|
||||
}
|
||||
},
|
||||
"errors":{
|
||||
"import-error":{
|
||||
"desc": "Vérifier que le dossier sélectionné est une installation de Beat Saber."
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"move-folder": {
|
||||
"success": {
|
||||
@@ -286,14 +324,14 @@
|
||||
"UNABLE_TO_LAUNCH": "Lancement impossible",
|
||||
"STEAM_NOT_RUNNING": "Steam n'est pas lancé",
|
||||
"OCULUS_NOT_RUNNING": "Oculus n'est pas lancé",
|
||||
"BS_ALREADY_RUNNING": "BeatSaber est déjà lancé",
|
||||
"BS_ALREADY_RUNNING": "Beat Saber est déjà lancé",
|
||||
"EXE_NOT_FINDED": "Fichiers manquants",
|
||||
"EXIT": "Arrêt brutal"
|
||||
},
|
||||
"msg": {
|
||||
"STEAM_NOT_RUNNING": "Steam doit être en cours d'exécution pour lancer BeatSaber.",
|
||||
"OCULUS_NOT_RUNNING": "Oculus doit être en cours d'exécution pour lancer BeatSaber.",
|
||||
"BS_ALREADY_RUNNING": "Ferme BeatSaber avant de le lancer à nouveau.",
|
||||
"STEAM_NOT_RUNNING": "Steam doit être en cours d'exécution pour lancer Beat Saber.",
|
||||
"OCULUS_NOT_RUNNING": "Oculus doit être en cours d'exécution pour lancer Beat Saber.",
|
||||
"BS_ALREADY_RUNNING": "Ferme Beat Saber avant de le lancer à nouveau.",
|
||||
"EXE_NOT_FINDED": "Quelques fichiers semblent manquants. Essaye de vérifier les fichiers.",
|
||||
"EXIT": "BeatSaber s'est arrêté brusquement, essaye de vérifier les fichiers."
|
||||
},
|
||||
@@ -317,12 +355,12 @@
|
||||
"CantClone": "Clonage impossible"
|
||||
},
|
||||
"msg": {
|
||||
"CantEditSteam": "Tu ne peut pas éditer la version Steam. Tu peut la cloner par contre."
|
||||
"CantEditSteam": "Tu ne peux pas éditer la version Steam. Tu peux la cloner par contre."
|
||||
}
|
||||
},
|
||||
"success": {
|
||||
"titles": {
|
||||
"CloningFinished": "Clonage terminer 🎉"
|
||||
"CloningFinished": "Clonage terminé 🎉"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -333,10 +371,10 @@
|
||||
"warning": "Mods installés 🤔"
|
||||
},
|
||||
"msg": {
|
||||
"success": "Tous les mods on été installés.",
|
||||
"success": "Tous les mods ont été installés.",
|
||||
"warning": "Un ou plusieurs mods n'ont pas pu être installés.",
|
||||
"errors": {
|
||||
"no-mods": "Aucun mods à installer.",
|
||||
"no-mods": "Aucun mod à installer.",
|
||||
"cannot-install-bsipa": "L'installation de BSIPA à échoué 😨"
|
||||
}
|
||||
}
|
||||
@@ -356,7 +394,7 @@
|
||||
"success": "Mods désintallés 🎉"
|
||||
},
|
||||
"msg": {
|
||||
"success": "Tous les mods on été désintallés.",
|
||||
"success": "Tous les mods ont été désintallés.",
|
||||
"errors": {
|
||||
"no-mods": "Aucun mod n'est installé dans dans cette version 😑"
|
||||
}
|
||||
@@ -380,6 +418,14 @@
|
||||
"success":"Installation du modèle terminée",
|
||||
"error":"Une erreur s'est produite lors de l'installation du modèle"
|
||||
}
|
||||
},
|
||||
"shared-folder":{
|
||||
"info": {
|
||||
"userdata-backup-created":{
|
||||
"title": "Sauvegarde créée",
|
||||
"msg": "Le partage du dossier 'UserData' peut générer des erreurs, en cas de soucis déliez le dossier pour restaurer la sauvegarde"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"modals": {
|
||||
@@ -413,20 +459,33 @@
|
||||
"label": "Rester connecté"
|
||||
}
|
||||
},
|
||||
"why-credentials": "Pourquoi mes identifiants sont nécessaires ?",
|
||||
"buttons": {
|
||||
"submit": "Se connecter"
|
||||
}
|
||||
},
|
||||
"steam-credentials":{
|
||||
"title": "Steam Credentials",
|
||||
"p-1": "Les informations d'identification ne sont utilisées que pour télécharger le jeu, car Steam doit vérifier que vous avez payé le jeu afin d'être autorisé à le télécharger. Ils ne sont pas sauvegardés et transmis directement à DepotDownloader. Si vous ne voulez pas entrer vos informations d'identification, vous pouvez suivre ce tutoriel :",
|
||||
"p-2": "puis cliquez sur l'icône de l'engrenage dans le coin supérieur droit et sélectionnez \"Importer une version\", sélectionnez le dossier où beat saber a été téléchargé (Si vous suivez le tutoriel ci-dessus, vous devriez avoir le bon emplacement)."
|
||||
},
|
||||
"bs-import-version":{
|
||||
"title": "Importer une version",
|
||||
"description": "Importe une version de BeatSaber pour profiter des fonctionnalités de BSManager. L'importation copiera le dossier d'installation de BeatSaber sélectionné dans le dossier de versions de BSManager.",
|
||||
"buttons":{
|
||||
"submit": "Importer une version"
|
||||
}
|
||||
},
|
||||
"bs-uninstall": {
|
||||
"title": "Désinstaller",
|
||||
"description": "Est-tu sûr de vouloir désinstaller BeatSaber {version} ? Tu vas devoir la retélécharger pour y jouer.",
|
||||
"description": "Es-tu sûr de vouloir désinstaller Beat Saber {version} ? Tu vas devoir la retélécharger pour y jouer.",
|
||||
"buttons": {
|
||||
"submit": "Désinstaller"
|
||||
}
|
||||
},
|
||||
"install-folder": {
|
||||
"title": "Dossier d'installation",
|
||||
"description": "Changer le dossier d'installation par défaut, va engendrer le déplacement de toutes les données installer vers le nouveau dossier.",
|
||||
"description": "Changer le dossier d'installation par défaut, cela va engendrer le déplacement de toutes les données installer vers le nouveau dossier.",
|
||||
"buttons": {
|
||||
"submit": "Choisir un dossier"
|
||||
}
|
||||
@@ -469,12 +528,12 @@
|
||||
"multiple": "Supprimer les maps ?"
|
||||
},
|
||||
"desc": {
|
||||
"single": "Est-tu sur de vouloir supprimer la map {name} ?",
|
||||
"multiple": "Est-tu sur de vouloir supprimer les {nb} maps ?"
|
||||
"single": "Es-tu sur de vouloir supprimer la map {name} ?",
|
||||
"multiple": "Es-tu sur de vouloir supprimer les {nb} maps ?"
|
||||
},
|
||||
"info": {
|
||||
"desc": {
|
||||
"single": "Cette map fait partie des maps paratagées",
|
||||
"single": "Cette map fait partie des maps partagées",
|
||||
"multiple": "Ces maps font parties des maps partagées"
|
||||
},
|
||||
"title": {
|
||||
@@ -505,7 +564,9 @@
|
||||
},
|
||||
"download-maps": {
|
||||
"search-btn": "Rechercher",
|
||||
"loading-maps": "Chargement des maps..."
|
||||
"loading-maps": "Chargement des maps...",
|
||||
"no-maps-found": "Aucune map trouvée",
|
||||
"no-internet": "Pas d'internet"
|
||||
},
|
||||
"mods-disclaimer":{
|
||||
"title": "avis de non-responsabilité",
|
||||
@@ -513,7 +574,16 @@
|
||||
"li-1": "Vous pouvez rencontrer des problèmes qui n'existent pas dans le jeu de base. 99.9% des bugs, plantages et ralentissements sont dus aux mods.",
|
||||
"li-2": "Les mods sont susceptibles de ne plus fonctionner à cause des mises à jour et c'est normal - soyez patient et respectueux lorsque cela se produit, parce que les moddeurs sont bénévoles et ont une vie.",
|
||||
"li-3": "Beat Games ne cherche pas volontairement à casser les mods. Ils souhaitent améliorer la base du jeu et parfois cela casse les mods, mais ce n'est pas dans leur objectif de tuer les mods.",
|
||||
"p-2": "N'attaquez pas les développeurs pour des problèmes relatifs aux mods, et inversement - les moddeurs et les développeurs sont deux groupes distincts. Ne sois pas idiot, d'accord ?"
|
||||
"p-2": "N'attaquez pas les développeurs pour des problèmes relatifs aux mods, et inversement - les moddeurs et les développeurs sont deux groupes distincts. Ne soyez pas idiots, d'accord ?"
|
||||
},
|
||||
"shared-folders":{
|
||||
"title": "Dossiers Partagés",
|
||||
"description": "Liez les dossiers de BeatSaber pour synchroniser leurs contenus avec les dossiers partagés des autres versions. Notez que la suppression de contenu sera également partagée.",
|
||||
"buttons": {
|
||||
"add-folder": "Ajouter un dossier",
|
||||
"link-folder": "Lier le dossier",
|
||||
"unlink-folder": "Délier le dossier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"maps": {
|
||||
@@ -655,4 +725,4 @@
|
||||
"PM"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+19021
-25
File diff suppressed because it is too large
Load Diff
+9
-1
@@ -74,7 +74,8 @@
|
||||
},
|
||||
"win": {
|
||||
"target": [
|
||||
"nsis"
|
||||
"nsis",
|
||||
"nsis-web"
|
||||
],
|
||||
"icon": "assets/favicon.ico",
|
||||
"certificateSha1": "f3363a89b084f8f6b616babea3c91f9d79e15000"
|
||||
@@ -225,6 +226,9 @@
|
||||
"dependencies": {
|
||||
"@node-steam/vdf": "^2.2.0",
|
||||
"@tippyjs/react": "^4.2.6",
|
||||
"@types/react-virtualized-auto-sizer": "^1.0.1",
|
||||
"@types/react-window": "^1.8.5",
|
||||
"@types/recursive-readdir": "^2.2.1",
|
||||
"archiver": "^5.3.1",
|
||||
"dateformat": "^5.0.3",
|
||||
"dot-prop": "^7.2.0",
|
||||
@@ -245,7 +249,11 @@
|
||||
"react-dom": "^18.2.0",
|
||||
"react-range": "^1.8.14",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-virtualized-auto-sizer": "^1.0.7",
|
||||
"react-window": "^1.8.8",
|
||||
"recursive-readdir": "^2.2.3",
|
||||
"regedit": "^5.1.1",
|
||||
"rfdc": "^1.3.0",
|
||||
"rxjs": "^7.5.6",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"semver": "^7.3.8",
|
||||
|
||||
Generated
+1228
-10
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bs-manager",
|
||||
"version": "1.0.0-alpha.3",
|
||||
"version": "1.1.0-alpha.1",
|
||||
"description": "A foundation for scalable desktop apps",
|
||||
"main": "./dist/main/main.js",
|
||||
"author": {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 965 KiB |
@@ -3,3 +3,5 @@ export const OCULUS_BS_DIR = "hyperbolic-magnetism-beat-saber"
|
||||
export const BS_APP_ID = "620980";
|
||||
export const BS_DEPOT = "620981";
|
||||
export const APP_NAME = "BSManager";
|
||||
|
||||
export const STEAMVR_APP_ID = "250820";
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { move } from "fs-extra";
|
||||
import { access, mkdir, rm, readdir, unlink, lstat, readlink } from "fs/promises";
|
||||
import path from "path";
|
||||
import { Observable } from "rxjs";
|
||||
import log from "electron-log"
|
||||
|
||||
export async function pathExist(path: string): Promise<boolean> {
|
||||
try{
|
||||
await access(path);
|
||||
return true;
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function ensureFolderExist(path: string): Promise<void> {
|
||||
if(await pathExist(path)){ return Promise.resolve(); }
|
||||
return mkdir(path, {recursive: true}).catch(log.error).then(() => {});
|
||||
}
|
||||
|
||||
export async function deleteFolder(folderPath: string): Promise<void> {
|
||||
if(!(await pathExist(folderPath))){ return; }
|
||||
return rm(folderPath, {recursive: true, force: true});
|
||||
}
|
||||
|
||||
export async function unlinkPath(path: string): Promise<void>{
|
||||
if(!(await pathExist(path))){ return; }
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
export async function getFoldersInFolder(folderPath: string): Promise<string[]> {
|
||||
if(!(await pathExist(folderPath))){ return []; }
|
||||
|
||||
const files = await readdir(folderPath, {withFileTypes: true});
|
||||
|
||||
const promises = files.map(async file => {
|
||||
if(file.isDirectory()){ return path.join(folderPath, file.name); }
|
||||
if(!file.isSymbolicLink()){ return undefined; }
|
||||
try{
|
||||
const targetPath = await readlink(path.join(folderPath, file.name));
|
||||
return (await lstat(targetPath)).isDirectory() ? path.join(folderPath, file.name) : undefined;
|
||||
}catch(e){
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
return (await Promise.all(promises)).filter(folder => folder);
|
||||
}
|
||||
|
||||
export function moveFolderContent(src: string, dest: string): Observable<Progression>{
|
||||
const progress: Progression = { current: 0, total: 0 };
|
||||
return new Observable<Progression>(subscriber => {
|
||||
subscriber.next(progress);
|
||||
(async () => {
|
||||
|
||||
const srcExist = await pathExist(src);
|
||||
|
||||
if(!srcExist){ return subscriber.complete(); }
|
||||
|
||||
ensureFolderExist(dest);
|
||||
|
||||
const files = await readdir(src, {encoding: "utf-8"});
|
||||
progress.total = files.length;
|
||||
|
||||
const promises = files.map(async file => {
|
||||
const srcFullPath = path.join(src, file);
|
||||
const destFullPath = path.join(dest, file);
|
||||
if(await pathExist(destFullPath)){
|
||||
progress.current++;
|
||||
return subscriber.next(progress);
|
||||
}
|
||||
await move(srcFullPath, destFullPath);
|
||||
progress.current++;
|
||||
subscriber.next(progress);
|
||||
});
|
||||
|
||||
Promise.allSettled(promises).then(() => subscriber.complete());
|
||||
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
export interface Progression<T = unknown>{
|
||||
total: number;
|
||||
current: number;
|
||||
extra?: T;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { UtilsService } from "../services/utils.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { SearchParams } from "shared/models/maps/beat-saver.model";
|
||||
import { BeatSaverService } from "../services/thrid-party/beat-saver/beat-saver.service";
|
||||
import log from "electron-log";
|
||||
|
||||
ipcMain.on("bsv-search-map", async (event, request: IpcRequest<SearchParams>) => {
|
||||
const utlis = UtilsService.getInstance();
|
||||
@@ -22,6 +23,7 @@ ipcMain.on("bsv-get-map-details-from-hashs", async (event, request: IpcRequest<s
|
||||
bsvService.getMapDetailsFromHashs(request.args).then(maps => {
|
||||
utlis.ipcSend(request.responceChannel, {success: true, data: maps});
|
||||
}).catch(e => {
|
||||
log.error(e);
|
||||
utlis.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { BSInstallerService, DownloadEventType } from '../services/bs-installer.service';
|
||||
import { BSInstallerService, DownloadEventType, DownloadInfo } from '../services/bs-installer.service';
|
||||
import { IpcRequest } from 'shared/models/ipc';
|
||||
import { InstallationLocationService } from '../services/installation-location.service';
|
||||
import { UtilsService } from '../services/utils.service';
|
||||
@@ -18,13 +17,6 @@ export interface InitDownloadInfoInterface {
|
||||
stay: boolean
|
||||
}
|
||||
|
||||
export interface DownloadInfo {
|
||||
bsVersion: BSVersion,
|
||||
username: string,
|
||||
password?: string,
|
||||
stay?: boolean
|
||||
}
|
||||
|
||||
ipcMain.on('is-dotnet-6-installed', async (event, request: IpcRequest<void>) => {
|
||||
const installer = BSInstallerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
@@ -65,4 +57,14 @@ ipcMain.on('bs-download.set-installation-folder', (event, request: IpcRequest<st
|
||||
});
|
||||
})
|
||||
|
||||
ipcMain.on('bs-download.import-version', (event, request: IpcRequest<string>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const installer = BSInstallerService.getInstance();
|
||||
installer.importVersion(request.args).catch(e => {
|
||||
utils.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
}).then(() => {
|
||||
utils.ipcSend(request.responceChannel, {success: true});
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
import { ipcMain } from "electron";
|
||||
|
||||
import { LocalMapsManagerService } from "../services/additional-content/local-maps-manager.service";
|
||||
import { UtilsService } from "../services/utils.service";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { BsvMapDetail } from "shared/models/maps";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
|
||||
ipcMain.on('get-version-maps', (event, request: IpcRequest<BSVersion>) => {
|
||||
const utilsService = UtilsService.getInstance();
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipc.on('load-version-maps', async (request: IpcRequest<BSVersion>, reply) => {
|
||||
const localMaps = LocalMapsManagerService.getInstance();
|
||||
|
||||
localMaps.getMaps(request.args).then(maps => {
|
||||
utilsService.ipcSend<BsmLocalMap[]>(request.responceChannel, {success: true, data: maps});
|
||||
}).catch(() => {
|
||||
utilsService.ipcSend(request.responceChannel, {success: false});
|
||||
})
|
||||
|
||||
reply(localMaps.getMaps(request.args));
|
||||
});
|
||||
|
||||
ipcMain.on("verion-have-maps-linked", async (event, request: IpcRequest<BSVersion>) => {
|
||||
ipc.on("verion-have-maps-linked", async (request: IpcRequest<BSVersion>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
@@ -26,7 +23,7 @@ ipcMain.on("verion-have-maps-linked", async (event, request: IpcRequest<BSVersio
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on("link-version-maps", async (event, request: IpcRequest<{version: BSVersion, keepMaps: boolean}>) => {
|
||||
ipc.on("link-version-maps", async (request: IpcRequest<{version: BSVersion, keepMaps: boolean}>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
@@ -38,7 +35,7 @@ ipcMain.on("link-version-maps", async (event, request: IpcRequest<{version: BSVe
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on("unlink-version-maps", async (event, request: IpcRequest<{version: BSVersion, keepMaps: boolean}>) => {
|
||||
ipc.on("unlink-version-maps", async (request: IpcRequest<{version: BSVersion, keepMaps: boolean}>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
@@ -50,40 +47,22 @@ ipcMain.on("unlink-version-maps", async (event, request: IpcRequest<{version: BS
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on("delete-maps", async (event, request: IpcRequest<{version: BSVersion, maps: BsmLocalMap[]}>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
ipc.on("delete-maps", async (request: IpcRequest<BsmLocalMap[]>, reply) => {
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
maps.deleteMaps(request.args.maps, request.args.version).then(() => {
|
||||
utils.ipcSend<void>(request.responceChannel, {success: true});
|
||||
}).catch(err => {
|
||||
utils.ipcSend<void>(request.responceChannel, {success: false, error: err});
|
||||
});
|
||||
reply(maps.deleteMaps(request.args));
|
||||
});
|
||||
|
||||
ipcMain.on("export-maps", async (event, request: IpcRequest<{version: BSVersion, maps: BsmLocalMap[], outPath: string}>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
ipc.on("export-maps", async (request: IpcRequest<{version: BSVersion, maps: BsmLocalMap[], outPath: string}>, reply) => {
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
maps.exportMaps(request.args.version, request.args.maps, request.args.outPath).then(() => {
|
||||
utils.ipcSend<void>(request.responceChannel, {success: true});
|
||||
}).catch(err => {
|
||||
utils.ipcSend<void>(request.responceChannel, {success: false, error: err});
|
||||
});
|
||||
reply(await maps.exportMaps(request.args.version, request.args.maps, request.args.outPath));
|
||||
});
|
||||
|
||||
ipcMain.on("download-map", async (event, request: IpcRequest<{map: BsvMapDetail, version: BSVersion}>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
ipc.on("download-map", async (request: IpcRequest<{map: BsvMapDetail, version: BSVersion}>, reply) => {
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
maps.downloadMap(request.args.map, request.args.version).then(() => {
|
||||
utils.ipcSend(request.responceChannel, {success: true});
|
||||
}).catch(err => {
|
||||
utils.ipcSend(request.responceChannel, {success: false, error: err});
|
||||
});
|
||||
reply(from(maps.downloadMap(request.args.map, request.args.version)))
|
||||
});
|
||||
|
||||
ipcMain.on("one-click-install-map", async (event, request: IpcRequest<BsvMapDetail>) => {
|
||||
ipc.on("one-click-install-map", async (request: IpcRequest<BsvMapDetail>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
|
||||
@@ -94,7 +73,7 @@ ipcMain.on("one-click-install-map", async (event, request: IpcRequest<BsvMapDeta
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on("register-maps-deep-link", async (event, request: IpcRequest<void>) => {
|
||||
ipc.on("register-maps-deep-link", async (request: IpcRequest<void>) => {
|
||||
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
@@ -109,7 +88,7 @@ ipcMain.on("register-maps-deep-link", async (event, request: IpcRequest<void>) =
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on("unregister-maps-deep-link", async (event, request: IpcRequest<void>) => {
|
||||
ipc.on("unregister-maps-deep-link", async (request: IpcRequest<void>) => {
|
||||
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
@@ -124,7 +103,7 @@ ipcMain.on("unregister-maps-deep-link", async (event, request: IpcRequest<void>)
|
||||
|
||||
});
|
||||
|
||||
ipcMain.on("is-map-deep-links-enabled", async (event, request: IpcRequest<void>) => {
|
||||
ipc.on("is-map-deep-links-enabled", async (request: IpcRequest<void>) => {
|
||||
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
@@ -137,4 +116,9 @@ ipcMain.on("is-map-deep-links-enabled", async (event, request: IpcRequest<void>)
|
||||
utils.ipcSend(request.responceChannel, {success: false});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ipc.on("get-version-maps-path", async (req: IpcRequest<BSVersion>, reply) => {
|
||||
const maps = LocalMapsManagerService.getInstance();
|
||||
reply(from(maps.getMapsFolderPath(req.args)));
|
||||
});
|
||||
@@ -6,6 +6,16 @@ import { exec } from 'child_process';
|
||||
import { IpcRequest } from 'shared/models/ipc';
|
||||
import { BSLocalVersionService } from '../services/bs-local-version.service';
|
||||
import { BsmException } from 'shared/models/bsm-exception.model';
|
||||
import { IpcService } from '../services/ipc.service';
|
||||
import { from } from 'rxjs';
|
||||
import path from 'path';
|
||||
import { pathExist } from '../helpers/fs.helpers';
|
||||
import { FolderLinkerService, LinkOptions } from '../services/folder-linker.service';
|
||||
import { LocalMapsManagerService } from '../services/additional-content/local-maps-manager.service';
|
||||
import { readJSON, writeJSON } from 'fs-extra';
|
||||
import log from "electron-log"
|
||||
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipcMain.on('bs-version.get-version-dict', (event, req: IpcRequest<void>) => {
|
||||
BSVersionLibService.getInstance().getAvailableVersions().then(versions => {
|
||||
@@ -26,7 +36,7 @@ ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest<void>)
|
||||
ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest<BSVersion>) => {
|
||||
const localVersionService = BSLocalVersionService.getInstance();
|
||||
const versionFolder = await localVersionService.getVersionPath(req.args);
|
||||
UtilsService.getInstance().pathExist(versionFolder) && exec(`start "" "${versionFolder}"`);
|
||||
(await pathExist(versionFolder)) && exec(`start "" "${versionFolder}"`);
|
||||
});
|
||||
|
||||
ipcMain.on("bs-version.edit", async (event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => {
|
||||
@@ -44,3 +54,91 @@ ipcMain.on("bs-version.clone", async (event, req: IpcRequest<{version: BSVersion
|
||||
UtilsService.getInstance().ipcSend(req.responceChannel, {success: false, error});
|
||||
});
|
||||
});
|
||||
|
||||
ipc.on("get-version-full-path", async (req: IpcRequest<BSVersion>, reply) => {
|
||||
const localVersions = BSLocalVersionService.getInstance();
|
||||
reply(from(
|
||||
localVersions.getVersionPath(req.args)
|
||||
));
|
||||
});
|
||||
|
||||
ipc.on("relative-version-path-to-full", async (req: IpcRequest<{version: BSVersion, relative: string}>, reply) => {
|
||||
path.isAbsolute(req.args.relative) && reply(from(Promise.resolve(req.args.relative)));
|
||||
|
||||
const localVersions = BSLocalVersionService.getInstance();
|
||||
const promise = localVersions.getVersionPath(req.args.version).catch(() => null).then(versionPath => {
|
||||
return path.join(versionPath, req.args.relative);
|
||||
});
|
||||
reply(from(promise));
|
||||
});
|
||||
|
||||
ipc.on("full-version-path-to-relative", async (req: IpcRequest<{version: BSVersion, fullPath: string}>, reply) => {
|
||||
const localVersions = BSLocalVersionService.getInstance();
|
||||
const promise = localVersions.getVersionPath(req.args.version).catch(() => null).then(versionPath => {
|
||||
return path.relative(versionPath, req.args.fullPath);
|
||||
});
|
||||
reply(from(promise));
|
||||
});
|
||||
|
||||
ipc.on("get-linked-folders", async (req: IpcRequest<BSVersion>, reply) => {
|
||||
const localVersions = BSLocalVersionService.getInstance();
|
||||
reply(from(localVersions.getLinkedFolders(req.args)));
|
||||
});
|
||||
|
||||
ipc.on("link-folder", async (req: IpcRequest<{ folder: string, options?: LinkOptions}>, reply) => {
|
||||
|
||||
req.args.options ??= {};
|
||||
|
||||
const linker = FolderLinkerService.getInstance();
|
||||
|
||||
const relativeMapsFolder = path.join(LocalMapsManagerService.LEVELS_ROOT_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER)
|
||||
|
||||
if(req.args.folder.includes(relativeMapsFolder)){
|
||||
return reply(from(linker.linkFolder(req.args.folder, {keepContents: req.args.options?.keepContents, intermediateFolder: LocalMapsManagerService.SHARED_MAPS_FOLDER})));
|
||||
}
|
||||
|
||||
if(req.args.folder.includes("UserData")){
|
||||
req.args.options = { ...req.args.options, backup: true };
|
||||
}
|
||||
|
||||
const res = from(linker.linkFolder(req.args.folder, req.args.options));
|
||||
|
||||
const jsonIPAPath = path.join(req.args.folder, "Beat Saber IPA.json");
|
||||
|
||||
if(!(await pathExist(jsonIPAPath))){ return reply(res); }
|
||||
|
||||
await res.toPromise();
|
||||
|
||||
try{
|
||||
const ipaData = (await readJSON(jsonIPAPath)) ?? {} as any;
|
||||
ipaData["YeetMods"] = false;
|
||||
await writeJSON(jsonIPAPath, ipaData, {spaces: 4});
|
||||
}catch(e){
|
||||
log.error("Disable YeetMods", e);
|
||||
}
|
||||
|
||||
reply(res);
|
||||
|
||||
});
|
||||
|
||||
ipc.on("unlink-folder", async (req: IpcRequest<{ folder: string, options?: LinkOptions}>, reply) => {
|
||||
|
||||
req.args.options ??= {};
|
||||
|
||||
const linker = FolderLinkerService.getInstance();
|
||||
|
||||
const relativeMapsFolder = path.join(LocalMapsManagerService.LEVELS_ROOT_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER)
|
||||
|
||||
if(req.args.folder.includes(relativeMapsFolder)){
|
||||
return reply(from(linker.unlinkFolder(req.args.folder, {...req.args.options, intermediateFolder: LocalMapsManagerService.SHARED_MAPS_FOLDER})));
|
||||
}
|
||||
|
||||
if(req.args.folder.includes("UserData")){
|
||||
req.args.options = { ...req.args.options, backup: true };
|
||||
}
|
||||
|
||||
reply(from(linker.unlinkFolder(req.args.folder, req.args.options)));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,16 @@ import { IpcRequest } from 'shared/models/ipc';
|
||||
import { SystemNotificationOptions } from 'shared/models/notification/system-notification.model';
|
||||
import { NotificationService } from '../services/notification.service';
|
||||
import { SteamService } from '../services/steam.service';
|
||||
import { IpcService } from '../services/ipc.service';
|
||||
import { from } from 'rxjs';
|
||||
import { fstat, lstat } from 'fs';
|
||||
import { pathExist } from '../helpers/fs.helpers';
|
||||
|
||||
|
||||
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
|
||||
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipcMain.on('window.close', async () => {
|
||||
const utils = UtilsService.getInstance();
|
||||
utils.getMainWindows("index.html")?.close();
|
||||
@@ -32,10 +38,10 @@ ipcMain.on('new-window', async (event, request: IpcRequest<string>) => {
|
||||
shell.openExternal(request.args);
|
||||
});
|
||||
|
||||
ipcMain.on('choose-folder', async (event, request: IpcRequest<void>) => {
|
||||
dialog.showOpenDialog({properties: ['openDirectory']}).then(res => {
|
||||
UtilsService.getInstance().ipcSend(request.responceChannel, {success: true, data: res});
|
||||
});
|
||||
ipc.on('choose-folder', async (req: IpcRequest<string>, reply) => {
|
||||
reply(
|
||||
from(dialog.showOpenDialog({properties: ['openDirectory'], defaultPath: req.args ?? ""}))
|
||||
)
|
||||
});
|
||||
|
||||
ipcMain.on("window.progression", async (event, request: IpcRequest<number>) => {
|
||||
@@ -71,4 +77,15 @@ ipcMain.on("open-steam", async (event, request: IpcRequest<void>) => {
|
||||
}).catch((e) => {
|
||||
utils.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
});
|
||||
});
|
||||
|
||||
ipc.on("is-folder-symlink", async (req: IpcRequest<string>, reply) => {
|
||||
const promise = new Promise<boolean>(async resolve => {
|
||||
if(!(await pathExist(req.args))){ return resolve(false); }
|
||||
lstat(req.args, (err, stats) => {
|
||||
if(err){ return resolve(false); }
|
||||
resolve(stats.isSymbolicLink());
|
||||
});
|
||||
});
|
||||
reply(from(promise));
|
||||
});
|
||||
@@ -2,6 +2,9 @@ import { ipcMain } from "electron";
|
||||
import { WindowManagerService } from "../services/window-manager.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { AppWindow } from "shared/models/window-manager/app-window.model";
|
||||
import { BSLauncherService } from "../services/bs-launcher.service";
|
||||
|
||||
const launcher = BSLauncherService.getInstance();
|
||||
|
||||
ipcMain.on("open-window-then-close-all", async (event, request: IpcRequest<AppWindow>) => {
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
@@ -12,11 +15,13 @@ ipcMain.on("open-window-then-close-all", async (event, request: IpcRequest<AppWi
|
||||
});
|
||||
|
||||
ipcMain.on("close-all-windows", async (event, request: IpcRequest<AppWindow>) => {
|
||||
await launcher.restoreSteamVR();
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
windowManager.closeAllWindows(request.args);
|
||||
});
|
||||
|
||||
ipcMain.on("close-windows", async (event, request: IpcRequest<AppWindow[]>) => {
|
||||
await launcher.restoreSteamVR();
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
windowManager.close(...request.args);
|
||||
});
|
||||
+3
-11
@@ -20,6 +20,7 @@ import { LocalMapsManagerService } from './services/additional-content/local-map
|
||||
import { LocalPlaylistsManagerService } from './services/additional-content/local-playlists-manager.service';
|
||||
import { LocalModelsManagerService } from './services/additional-content/local-models-manager.service';
|
||||
import { APP_NAME } from './constants';
|
||||
import { BSLauncherService } from './services/bs-launcher.service';
|
||||
|
||||
const isDebug = process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true';
|
||||
|
||||
@@ -31,9 +32,6 @@ log.transports.file.resolvePath = (() => {
|
||||
|
||||
log.catchErrors();
|
||||
|
||||
const utilsService = UtilsService.getInstance();
|
||||
utilsService.setAssetsPath(app.isPackaged ? path.join(process.resourcesPath, 'assets') : path.join(__dirname, '../../assets'));
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const sourceMapSupport = require('source-map-support');
|
||||
sourceMapSupport.install();
|
||||
@@ -63,14 +61,6 @@ const initServicesMustBeInitialized = () => {
|
||||
// Model
|
||||
}
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
// Respect the OSX convention of having the application in memory even
|
||||
// after all windows have been closed
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
if(!gotTheLock){
|
||||
@@ -108,5 +98,7 @@ else{
|
||||
callback(pathname);
|
||||
});
|
||||
|
||||
BSLauncherService.getInstance().restoreSteamVR();
|
||||
|
||||
}).catch(log.error);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import archiver from "archiver";
|
||||
import { createWriteStream } from "fs";
|
||||
import { Observable } from "rxjs";
|
||||
import recursive from "recursive-readdir";
|
||||
import { lstatSync } from "fs";
|
||||
import * as _path from "path";
|
||||
import { ArchiveProgress } from "shared/models/archive.interface";
|
||||
|
||||
export class Archive{
|
||||
|
||||
private archive: archiver.Archiver;
|
||||
private readonly output: string;
|
||||
|
||||
private readonly directories: string[] = [];
|
||||
private readonly files: string[] = [];
|
||||
|
||||
constructor(output: string, options?: archiver.ArchiverOptions){
|
||||
this.output = output;
|
||||
this.initArchive(options);
|
||||
}
|
||||
|
||||
private initArchive(options?: archiver.ArchiverOptions): void{
|
||||
const defaultOptions: archiver.ArchiverOptions = {
|
||||
zlib: {level: 9}
|
||||
};
|
||||
|
||||
this.archive = archiver("zip", {...defaultOptions, ...options});
|
||||
}
|
||||
|
||||
private async loadTotalFiles(): Promise<number>{
|
||||
let totalFiles = this.files.length;
|
||||
for(const path of this.directories){
|
||||
const files = await recursive(path);
|
||||
totalFiles += files.length;
|
||||
}
|
||||
return totalFiles;
|
||||
}
|
||||
|
||||
public addDirectory(path: string, destPath?: string|false): void{
|
||||
this.directories.push(path);
|
||||
destPath = destPath === false ? false : _path.basename(path);
|
||||
this.archive.directory(path, destPath);
|
||||
}
|
||||
|
||||
public addFile(path: string, destPath?: string): void{
|
||||
this.files.push(path);
|
||||
destPath = destPath ||= _path.basename(path);
|
||||
this.archive.file(path, {name: destPath});
|
||||
}
|
||||
|
||||
|
||||
public finalize(): Observable<ArchiveProgress>{
|
||||
|
||||
const progress: ArchiveProgress = {
|
||||
totalFiles: 0,
|
||||
prossesedFiles: 0
|
||||
};
|
||||
|
||||
return new Observable<ArchiveProgress>(observer => {
|
||||
(async () => {
|
||||
|
||||
progress.totalFiles = await this.loadTotalFiles();
|
||||
|
||||
this.archive.on("entry", e => {
|
||||
if(e.stats.isDirectory()){ return; }
|
||||
progress.prossesedFiles++;
|
||||
observer.next(progress);
|
||||
});
|
||||
|
||||
this.archive.pipe(createWriteStream(this.output));
|
||||
|
||||
this.archive.on("error", err => observer.error(err));
|
||||
this.archive.finalize().then(() => observer.complete());
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+7
-5
@@ -1,21 +1,23 @@
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
|
||||
export type Channels = any;
|
||||
import { IpcChannel } from 'shared/models/ipc/ipc-response.interface';
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
ipcRenderer: {
|
||||
sendMessage(channel: Channels, args: unknown[]) {
|
||||
sendMessage(channel: IpcChannel, args: unknown[]) {
|
||||
ipcRenderer.send(channel, args);
|
||||
},
|
||||
on(channel: Channels, func: (...args: unknown[]) => void) {
|
||||
on(channel: IpcChannel, func: (...args: unknown[]) => void) {
|
||||
const subscription = (_event: IpcRendererEvent, ...args: unknown[]) =>
|
||||
func(...args);
|
||||
ipcRenderer.on(channel, subscription);
|
||||
|
||||
return () => ipcRenderer.removeListener(channel, subscription);
|
||||
},
|
||||
once(channel: Channels, func: (...args: unknown[]) => void) {
|
||||
once(channel: IpcChannel, func: (...args: unknown[]) => void) {
|
||||
ipcRenderer.once(channel, (_event, ...args) => func(...args));
|
||||
},
|
||||
removeAllListeners(channel: IpcChannel) {
|
||||
ipcRenderer.removeAllListeners(channel);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import path from "path";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BsvMapDetail, RawMapInfoData } from "shared/models/maps";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { BsmLocalMap, BsmLocalMapsProgress, DeleteMapsProgress } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { BSLocalVersionService } from "../bs-local-version.service";
|
||||
import { InstallationLocationService } from "../installation-location.service";
|
||||
import { UtilsService } from "../utils.service";
|
||||
import crypto from "crypto";
|
||||
import { lstatSync, symlinkSync, unlinkSync, readdirSync, createWriteStream } from "fs";
|
||||
import { lstatSync, unlinkSync } from "fs";
|
||||
import { copySync } from "fs-extra";
|
||||
import StreamZip from "node-stream-zip";
|
||||
import { RequestService } from "../request.service";
|
||||
import sanitize from "sanitize-filename";
|
||||
import archiver from "archiver";
|
||||
import { DeepLinkService } from "../deep-link.service";
|
||||
import log from 'electron-log';
|
||||
import { WindowManagerService } from "../window-manager.service";
|
||||
import { ipcMain } from "electron";
|
||||
import { IpcRequest } from 'shared/models/ipc';
|
||||
import { Observable } from "rxjs";
|
||||
import { Archive } from "../../models/archive.class";
|
||||
import { deleteFolder, ensureFolderExist, getFoldersInFolder, pathExist } from "../../helpers/fs.helpers";
|
||||
import { readFile } from "fs/promises";
|
||||
import { FolderLinkerService } from "../folder-linker.service";
|
||||
|
||||
export class LocalMapsManagerService {
|
||||
|
||||
@@ -27,8 +31,9 @@ export class LocalMapsManagerService {
|
||||
return LocalMapsManagerService.instance;
|
||||
}
|
||||
|
||||
private readonly LEVELS_ROOT_FOLDER = "Beat Saber_Data";
|
||||
private readonly CUSTOM_LEVELS_FOLDER = "CustomLevels";
|
||||
public static readonly LEVELS_ROOT_FOLDER = "Beat Saber_Data";
|
||||
public static readonly CUSTOM_LEVELS_FOLDER = "CustomLevels";
|
||||
public static readonly SHARED_MAPS_FOLDER = "SharedMaps";
|
||||
|
||||
private readonly DEEP_LINKS = {
|
||||
BeatSaver: "beatsaver",
|
||||
@@ -41,6 +46,7 @@ export class LocalMapsManagerService {
|
||||
private readonly reqService: RequestService;
|
||||
private readonly deepLink: DeepLinkService;
|
||||
private readonly windows: WindowManagerService;
|
||||
private readonly linker = FolderLinkerService.getInstance();
|
||||
|
||||
private constructor(){
|
||||
this.localVersion = BSLocalVersionService.getInstance();
|
||||
@@ -49,50 +55,50 @@ export class LocalMapsManagerService {
|
||||
this.reqService = RequestService.getInstance();
|
||||
this.deepLink = DeepLinkService.getInstance();
|
||||
this.windows = WindowManagerService.getInstance();
|
||||
this.linker = FolderLinkerService.getInstance();
|
||||
|
||||
this.deepLink.addLinkOpenedListener(this.DEEP_LINKS.BeatSaver, (link) => {
|
||||
this.deepLink.addLinkOpenedListener(this.DEEP_LINKS.BeatSaver, link => {
|
||||
log.info("DEEP-LINK RECEIVED FROM", this.DEEP_LINKS.BeatSaver, link);
|
||||
this.openOneClickDownloadMapWindow(new URL(link).host);
|
||||
});
|
||||
|
||||
this.deepLink.addLinkOpenedListener(this.DEEP_LINKS.ScoreSaber, (link) => {
|
||||
this.deepLink.addLinkOpenedListener(this.DEEP_LINKS.ScoreSaber, link => {
|
||||
log.info("DEEP-LINK RECEIVED FROM", this.DEEP_LINKS.ScoreSaber, link);
|
||||
this.openOneClickDownloadMapWindow(new URL(link).host, true);
|
||||
});
|
||||
}
|
||||
|
||||
public async getMapsFolderPath(version?: BSVersion): Promise<string>{
|
||||
if(version){ return path.join(await this.localVersion.getVersionPath(version), this.LEVELS_ROOT_FOLDER, this.CUSTOM_LEVELS_FOLDER); }
|
||||
const sharedMapsPath = path.join(this.installLocation.sharedMapsPath, this.CUSTOM_LEVELS_FOLDER);
|
||||
if(!(await this.utils.pathExist(sharedMapsPath))){
|
||||
this.utils.createFolderIfNotExist(sharedMapsPath);
|
||||
|
||||
if(version){ return path.join(await this.localVersion.getVersionPath(version), LocalMapsManagerService.LEVELS_ROOT_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER); }
|
||||
const sharedMapsPath = path.join(this.installLocation.sharedContentPath, LocalMapsManagerService.SHARED_MAPS_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER);
|
||||
if(!(await pathExist(sharedMapsPath))){
|
||||
await ensureFolderExist(sharedMapsPath);
|
||||
}
|
||||
return sharedMapsPath;
|
||||
}
|
||||
|
||||
private async computeMapHash(mapPath: string, rawInfoString: string): Promise<string>{
|
||||
const mapRawInfo = JSON.parse(rawInfoString);
|
||||
let content = rawInfoString;
|
||||
const shasum = crypto.createHash("sha1");
|
||||
shasum.update(rawInfoString);
|
||||
for(const set of mapRawInfo._difficultyBeatmapSets){
|
||||
for(const diff of set._difficultyBeatmaps){
|
||||
const diffFilePath = path.join(mapPath, diff._beatmapFilename);
|
||||
if(!await this.utils.pathExist(diffFilePath)){ continue; }
|
||||
const diffContent = (await this.utils.readFileAsync(diffFilePath)).toString();
|
||||
content += diffContent;
|
||||
const diffContent = await readFile(diffFilePath, {encoding: "utf-8"}).catch(() => null);
|
||||
diffContent && shasum.update(diffContent);
|
||||
}
|
||||
}
|
||||
|
||||
const shasum = crypto.createHash("sha1");
|
||||
shasum.update(content);
|
||||
|
||||
return shasum.digest("hex");
|
||||
}
|
||||
|
||||
private async loadMapInfoFromPath(mapPath: string): Promise<BsmLocalMap>{
|
||||
const infoFilePath = path.join(mapPath, "Info.dat");
|
||||
|
||||
if(!(await this.utils.pathExist(infoFilePath))){ return null; }
|
||||
if(!(await pathExist(infoFilePath))){ return null; }
|
||||
|
||||
const rawInfoString = await (await (this.utils.readFileAsync(infoFilePath))).toString();
|
||||
const rawInfoString = await readFile(infoFilePath, {encoding: "utf-8"});
|
||||
|
||||
const rawInfo: RawMapInfoData = JSON.parse(rawInfoString);
|
||||
const coverUrl = new URL(`file:///${path.join(mapPath, rawInfo._coverImageFilename)}`).href;
|
||||
@@ -100,13 +106,13 @@ export class LocalMapsManagerService {
|
||||
|
||||
const hash = await this.computeMapHash(mapPath, rawInfoString);
|
||||
|
||||
return {rawInfo, coverUrl, songUrl, hash};
|
||||
return {rawInfo, coverUrl, songUrl, hash, path: mapPath};
|
||||
}
|
||||
|
||||
private async downloadMapZip(zipUrl: string): Promise<{zip: StreamZip.StreamZipAsync, zipPath: string}>{
|
||||
const fileName = path.basename(zipUrl);
|
||||
const tempPath = this.utils.getTempPath();
|
||||
this.utils.createFolderIfNotExist(this.utils.getTempPath());
|
||||
await ensureFolderExist(this.utils.getTempPath());
|
||||
const dest = path.join(tempPath, fileName);
|
||||
|
||||
const zipPath = await this.reqService.downloadFile(zipUrl, dest);
|
||||
@@ -115,28 +121,6 @@ export class LocalMapsManagerService {
|
||||
return {zip, zipPath};
|
||||
}
|
||||
|
||||
private async getAbsoluteFolderOfMaps(maps: BsmLocalMap[], version: BSVersion): Promise<string[]>{
|
||||
|
||||
const mapsFolder = await this.getMapsFolderPath(version);
|
||||
|
||||
const res: string[] = [];
|
||||
const mapHashs = maps.map(map => map.hash);
|
||||
|
||||
const mapsFolders = readdirSync(mapsFolder, {withFileTypes: true});
|
||||
|
||||
for(const content of mapsFolders){
|
||||
if(!content.isDirectory()){ continue; }
|
||||
const mapFolderPath = path.join(mapsFolder, content.name);
|
||||
const { hash } = await this.loadMapInfoFromPath(mapFolderPath);
|
||||
if(mapHashs.includes(hash)){
|
||||
res.push(mapFolderPath);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
private openOneClickDownloadMapWindow(mapId: string, isHash = false): void{
|
||||
|
||||
ipcMain.once("one-click-map-info", async (event, req: IpcRequest<void>) => {
|
||||
@@ -147,21 +131,51 @@ export class LocalMapsManagerService {
|
||||
|
||||
}
|
||||
|
||||
public async getMaps(version?: BSVersion): Promise<BsmLocalMap[]>{
|
||||
const levelsFolder = await this.getMapsFolderPath(version);
|
||||
public getMaps(version?: BSVersion): Observable<BsmLocalMapsProgress>{
|
||||
|
||||
const levelsPath = (await this.utils.pathExist(levelsFolder)) ? this.utils.listDirsInDir(levelsFolder, true) : [];
|
||||
const progression: BsmLocalMapsProgress = {
|
||||
total: 0,
|
||||
loaded: 0,
|
||||
maps: []
|
||||
};
|
||||
|
||||
const mapsInfo = await Promise.all(levelsPath.map(levelPath => this.loadMapInfoFromPath(levelPath)));
|
||||
return new Observable<BsmLocalMapsProgress>(observer => {
|
||||
(async () => {
|
||||
const levelsFolder = await this.getMapsFolderPath(version);
|
||||
|
||||
return mapsInfo.filter(info => !!info);
|
||||
const levelsPaths = (await pathExist(levelsFolder)) ? await getFoldersInFolder(levelsFolder) : [];
|
||||
|
||||
progression.total = levelsPaths.length;
|
||||
|
||||
const promises = levelsPaths.map(async levelPath => {
|
||||
const mapInfo = await this.loadMapInfoFromPath(levelPath);
|
||||
if(!mapInfo){ return null; }
|
||||
progression.loaded++;
|
||||
observer.next(progression);
|
||||
return mapInfo;
|
||||
});
|
||||
|
||||
const mapsInfo = (await Promise.allSettled(promises)).reduce((acc, mapInfo) => {
|
||||
if(mapInfo.status === "fulfilled" && mapInfo.value){
|
||||
acc.push(mapInfo.value);
|
||||
}
|
||||
return acc;
|
||||
} ,[] as BsmLocalMap[]);
|
||||
|
||||
progression.maps = mapsInfo;
|
||||
|
||||
observer.next(progression);
|
||||
|
||||
observer.complete();
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
public async versionIsLinked(version: BSVersion): Promise<boolean>{
|
||||
|
||||
const levelsPath = await this.getMapsFolderPath(version);
|
||||
|
||||
const isPathExist = await this.utils.pathExist(levelsPath);
|
||||
const isPathExist = await pathExist(levelsPath);
|
||||
|
||||
if(!isPathExist){ return false; }
|
||||
|
||||
@@ -169,53 +183,40 @@ export class LocalMapsManagerService {
|
||||
}
|
||||
|
||||
public async linkVersionMaps(version: BSVersion, keepMaps: boolean): Promise<void>{
|
||||
|
||||
if(await this.versionIsLinked(version)){ return; }
|
||||
|
||||
const sharedMapsPath = await this.getMapsFolderPath();
|
||||
const versionMapsPath = await this.getMapsFolderPath(version);
|
||||
|
||||
if(keepMaps){
|
||||
await this.utils.moveDirContent(versionMapsPath, sharedMapsPath);
|
||||
}
|
||||
|
||||
await this.utils.deleteFolder(versionMapsPath);
|
||||
|
||||
symlinkSync(sharedMapsPath, versionMapsPath, "junction");
|
||||
return this.linker.linkFolder(versionMapsPath, {keepContents: keepMaps, intermediateFolder: LocalMapsManagerService.SHARED_MAPS_FOLDER});
|
||||
}
|
||||
|
||||
public async unlinkVersionMaps(version: BSVersion, keepMaps: boolean): Promise<void>{
|
||||
|
||||
const sharedMapsPath = await this.getMapsFolderPath();
|
||||
const versionMapsPath = await this.getMapsFolderPath(version);
|
||||
|
||||
if(await this.versionIsLinked(version)){
|
||||
unlinkSync(versionMapsPath);
|
||||
}
|
||||
|
||||
this.utils.createFolderIfNotExist(versionMapsPath);
|
||||
|
||||
if(keepMaps){
|
||||
copySync(sharedMapsPath, versionMapsPath);
|
||||
}
|
||||
|
||||
return this.linker.unlinkFolder(versionMapsPath, {keepContents: keepMaps, intermediateFolder: LocalMapsManagerService.SHARED_MAPS_FOLDER});
|
||||
}
|
||||
|
||||
public async deleteMaps(maps: BsmLocalMap[], verion?: BSVersion){
|
||||
public deleteMaps(maps: BsmLocalMap[]): Observable<DeleteMapsProgress>{
|
||||
|
||||
const mapsFolders = await this.getAbsoluteFolderOfMaps(maps, verion);
|
||||
const mapsFolders = maps.map(map => map.path);
|
||||
const mapsHashsToDelete = maps.map(map => map.hash);
|
||||
|
||||
for(const folder of mapsFolders){
|
||||
const { hash } = await this.loadMapInfoFromPath(folder);
|
||||
if(mapsHashsToDelete.includes(hash)){
|
||||
await this.utils.deleteFolder(folder);
|
||||
}
|
||||
}
|
||||
|
||||
return new Observable<DeleteMapsProgress>(observer => {
|
||||
(async () => {
|
||||
const progress: DeleteMapsProgress = { total: maps.length, deleted: 0 };
|
||||
try{
|
||||
for(const folder of mapsFolders){
|
||||
const detail = await this.loadMapInfoFromPath(folder);
|
||||
if(!mapsHashsToDelete.includes(detail?.hash)){ continue; }
|
||||
await deleteFolder(folder);
|
||||
progress.deleted++;
|
||||
observer.next(progress);
|
||||
}
|
||||
}catch(e){
|
||||
observer.error(e);
|
||||
}
|
||||
observer.complete();
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
public async downloadMap(map: BsvMapDetail, version?: BSVersion): Promise<string>{
|
||||
public async downloadMap(map: BsvMapDetail, version?: BSVersion): Promise<BsmLocalMap>{
|
||||
|
||||
if(!map.versions.at(0).hash){ throw "Cannot download map, no hash found"; }
|
||||
|
||||
@@ -231,41 +232,33 @@ export class LocalMapsManagerService {
|
||||
|
||||
if(!zip){ throw `Cannot download ${zipUrl}`; }
|
||||
|
||||
this.utils.createFolderIfNotExist(mapPath);
|
||||
await ensureFolderExist(mapPath);
|
||||
|
||||
await zip.extract(null, mapPath);
|
||||
await zip.close();
|
||||
|
||||
unlinkSync(zipPath);
|
||||
|
||||
return mapPath;
|
||||
const localMap = await this.loadMapInfoFromPath(mapPath);
|
||||
localMap.bsaverInfo = map;
|
||||
|
||||
return localMap;
|
||||
}
|
||||
|
||||
public async exportMaps(version: BSVersion, maps: BsmLocalMap[], outPath: string){
|
||||
|
||||
const output = createWriteStream(outPath);
|
||||
const archive = archiver("zip", {zlib: {level: 9}});
|
||||
|
||||
archive.pipe(output);
|
||||
archive.on("error", (e) => {throw e});
|
||||
const archive = new Archive(outPath);
|
||||
|
||||
if(!maps || maps.length === 0){
|
||||
|
||||
const mapsFolder = await this.getMapsFolderPath(version);
|
||||
archive.directory(mapsFolder, false);
|
||||
|
||||
archive.addDirectory(mapsFolder, false);
|
||||
}
|
||||
else{
|
||||
|
||||
const mapsFolders = await this.getAbsoluteFolderOfMaps(maps, version);
|
||||
|
||||
for(const folder of mapsFolders){
|
||||
archive.directory(folder, path.basename(folder));
|
||||
}
|
||||
|
||||
const mapsFolders = maps.map(map => map.path);
|
||||
mapsFolders.forEach(maps => archive.addDirectory(maps));
|
||||
}
|
||||
|
||||
await archive.finalize();
|
||||
return archive.finalize()
|
||||
|
||||
}
|
||||
|
||||
@@ -281,9 +274,9 @@ export class LocalMapsManagerService {
|
||||
|
||||
const versionMapsPath = await this.getMapsFolderPath(version);
|
||||
|
||||
this.utils.createFolderIfNotExist(versionMapsPath);
|
||||
await ensureFolderExist(versionMapsPath);
|
||||
|
||||
copySync(downloadedMap, path.join(versionMapsPath, path.basename(downloadedMap)), {overwrite: true});
|
||||
copySync(downloadedMap.path, path.join(versionMapsPath, path.basename(downloadedMap.path)), {overwrite: true});
|
||||
|
||||
}
|
||||
|
||||
@@ -301,6 +294,4 @@ export class LocalMapsManagerService {
|
||||
return Array.from(Object.values(this.DEEP_LINKS)).every(link => this.deepLink.isDeepLinkRegistred(link));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import path from "path";
|
||||
import { RequestService } from "../request.service";
|
||||
import { copyFileSync } from "fs-extra";
|
||||
import sanitize from "sanitize-filename";
|
||||
import { ensureFolderExist } from "../../helpers/fs.helpers";
|
||||
|
||||
export class LocalModelsManagerService {
|
||||
|
||||
@@ -74,7 +75,7 @@ export class LocalModelsManagerService {
|
||||
const versionPath = await this.localVersion.getVersionPath(version);
|
||||
const modelFolderPath = path.join(versionPath, this.MODEL_TYPE_FOLDER[type]);
|
||||
|
||||
this.utils.createFolderIfNotExist(modelFolderPath);
|
||||
await ensureFolderExist(modelFolderPath);
|
||||
|
||||
return modelFolderPath;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { BPList, DownloadPlaylistProgression } from "shared/models/playlists/pla
|
||||
import { copyFileSync, readFileSync } from "fs";
|
||||
import { BeatSaverService } from "../thrid-party/beat-saver/beat-saver.service";
|
||||
import { copySync } from "fs-extra";
|
||||
import { ensureFolderExist, pathExist } from "../../helpers/fs.helpers";
|
||||
|
||||
export class LocalPlaylistsManagerService {
|
||||
|
||||
@@ -80,7 +81,7 @@ export class LocalPlaylistsManagerService {
|
||||
|
||||
const folder = path.join(versionFolder, this.PLAYLISTS_FOLDER);
|
||||
|
||||
await this.utils.createFolderIfNotExist(folder)
|
||||
await ensureFolderExist(folder)
|
||||
|
||||
return folder;
|
||||
|
||||
@@ -92,7 +93,7 @@ export class LocalPlaylistsManagerService {
|
||||
|
||||
const bpListDest = path.join(playlistFolder, path.basename(bpListUrlOrPath));
|
||||
|
||||
if(this.utils.pathExist(bpListUrlOrPath)){
|
||||
if(await pathExist(bpListUrlOrPath)){
|
||||
copyFileSync(bpListUrlOrPath, bpListDest);
|
||||
}
|
||||
else{
|
||||
@@ -105,7 +106,7 @@ export class LocalPlaylistsManagerService {
|
||||
|
||||
private async readPlaylistFile(path: string): Promise<BPList>{
|
||||
|
||||
if(!this.utils.pathExist(path)){ throw `bplist file not exist at ${path}`; }
|
||||
if(!(await pathExist(path))){ throw `bplist file not exist at ${path}`; }
|
||||
|
||||
const rawContent = readFileSync(path).toString();
|
||||
|
||||
@@ -163,7 +164,7 @@ export class LocalPlaylistsManagerService {
|
||||
...res.value,
|
||||
current: null,
|
||||
downloadedMaps: [...res.value.downloadedMaps, map],
|
||||
mapsPath: [...res.value.mapsPath, mapPath],
|
||||
mapsPath: [...res.value.mapsPath, mapPath.path],
|
||||
progression
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable prefer-promise-reject-errors */
|
||||
import { BS_APP_ID, BS_DEPOT } from "../constants";
|
||||
import path from "path";
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { BSVersion, PartialBSVersion } from 'shared/bs-version.interface';
|
||||
import { UtilsService } from "./utils.service";
|
||||
import { ChildProcessWithoutNullStreams, spawn, spawnSync } from "child_process";
|
||||
import log from "electron-log";
|
||||
@@ -9,6 +10,9 @@ import { ctrlc } from "ctrlc-windows";
|
||||
import { BSLocalVersionService } from "./bs-local-version.service";
|
||||
import isOnline from 'is-online';
|
||||
import { WindowManagerService } from "./window-manager.service";
|
||||
import { copy, copySync } from "fs-extra";
|
||||
import { clean, satisfies } from "semver";
|
||||
import { ensureFolderExist, pathExist } from "../helpers/fs.helpers";
|
||||
|
||||
export class BSInstallerService{
|
||||
|
||||
@@ -27,7 +31,7 @@ export class BSInstallerService{
|
||||
this.localVersionService = BSLocalVersionService.getInstance();
|
||||
this.windows = WindowManagerService.getInstance();
|
||||
|
||||
this.windows.getWindows("index.html")?.on("close", () => {
|
||||
this.windows.getWindow("index.html")?.on("close", () => {
|
||||
this.killDownloadProcess();
|
||||
});
|
||||
}
|
||||
@@ -37,8 +41,12 @@ export class BSInstallerService{
|
||||
return BSInstallerService.instance;
|
||||
}
|
||||
|
||||
private escapeSpaces(path: string): string{
|
||||
return `\"${path}\"`
|
||||
}
|
||||
|
||||
private getDepotDownloaderExePath(): string{
|
||||
return path.join(this.utils.getAssetsScriptsPath(), 'depot-downloader', 'DepotDownloader.exe');
|
||||
return this.escapeSpaces(path.join(this.utils.getAssetsScriptsPath(), 'depot-downloader', 'DepotDownloader.exe'));
|
||||
}
|
||||
|
||||
private removeSpecialSchar(txt: string): string{ return txt.replaceAll(/\[|\]/g, ""); }
|
||||
@@ -65,16 +73,19 @@ export class BSInstallerService{
|
||||
});
|
||||
}
|
||||
|
||||
public async isDotNet6Installed(): Promise<boolean>{
|
||||
public async isDotNet6Installed(): Promise<boolean>{
|
||||
try{
|
||||
const process = spawnSync(this.getDepotDownloaderExePath());
|
||||
const out = process.output.toString();
|
||||
if(out.includes(".NET runtime can be found at")){ return false; }
|
||||
const process = spawnSync(this.getDepotDownloaderExePath(), {shell: true});
|
||||
if(process.stderr.toString()){
|
||||
log.error("no dotnet", process.stderr.toString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(e){
|
||||
log.error("Error while checking .NET 6", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async downloadBsVersion(downloadInfos: DownloadInfo): Promise<DownloadEvent>{
|
||||
@@ -84,7 +95,14 @@ export class BSInstallerService{
|
||||
if(!bsVersion){ return {type: "[Error]"}; }
|
||||
if(!(await isOnline({timeout: 1500}))){ throw "no-internet"; }
|
||||
|
||||
this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory);
|
||||
await ensureFolderExist(this.installLocationService.versionsDirectory);
|
||||
|
||||
const versionPath = await this.localVersionService.getVersionPath(bsVersion)
|
||||
|
||||
const dest = !downloadInfos.isVerification ? await this.getPathNotAleardyExist(versionPath) : versionPath;
|
||||
|
||||
const downloadVersion: BSVersion = {...downloadInfos.bsVersion, ...(path.basename(dest) !== downloadInfos.bsVersion.BSVersion && {name: path.basename(dest)})}
|
||||
|
||||
this.downloadProcess = spawn(
|
||||
this.getDepotDownloaderExePath(),
|
||||
[
|
||||
@@ -92,12 +110,13 @@ export class BSInstallerService{
|
||||
`-depot ${BS_DEPOT}`,
|
||||
`-manifest ${bsVersion.BSManifest}`,
|
||||
`-username ${downloadInfos.username}`,
|
||||
`-dir \"${this.localVersionService.getVersionFolder(bsVersion)}\"`,
|
||||
(downloadInfos.stay || !downloadInfos.password) && "-remember-password"
|
||||
`-dir \"${this.localVersionService.getVersionFolder(downloadVersion)}\"`
|
||||
],
|
||||
{shell: true, cwd: this.installLocationService.versionsDirectory}
|
||||
);
|
||||
|
||||
this.utils.ipcSend("start-download-version", {success: true, data: downloadVersion});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.downloadProcess.stdout.on('data', data => {
|
||||
@@ -142,16 +161,25 @@ export class BSInstallerService{
|
||||
this.downloadProcess.stdout.on('error', (err) => {
|
||||
log.error("BS-DOWNLOAD ERROR", err.toString());
|
||||
this.killDownloadProcess();
|
||||
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
|
||||
reject("dotnet");
|
||||
}
|
||||
reject();
|
||||
});
|
||||
this.downloadProcess.stderr.on('data', (err) => {
|
||||
log.error("BS-DOWNLOAD ERROR", err.toString());
|
||||
this.killDownloadProcess();
|
||||
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
|
||||
reject("dotnet");
|
||||
}
|
||||
reject();
|
||||
});
|
||||
this.downloadProcess.stderr.on('error', (err) => {
|
||||
log.error("BS-DOWNLOAD ERROR", err.toString());
|
||||
this.killDownloadProcess();
|
||||
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
|
||||
reject("dotnet");
|
||||
}
|
||||
reject();
|
||||
});
|
||||
|
||||
@@ -159,6 +187,34 @@ export class BSInstallerService{
|
||||
})
|
||||
}
|
||||
|
||||
private async getPathNotAleardyExist(path: string): Promise<string>{
|
||||
let destPath = path;
|
||||
let folderExist = await pathExist(destPath);
|
||||
let i = 0;
|
||||
|
||||
while(folderExist){
|
||||
i++;
|
||||
destPath = `${path} (${i})`;
|
||||
folderExist = await pathExist(destPath);
|
||||
}
|
||||
|
||||
return destPath
|
||||
}
|
||||
|
||||
public async importVersion(path: string): Promise<PartialBSVersion>{
|
||||
|
||||
const rawBsVersion = await this.localVersionService.getVersionOfBSFolder(path);
|
||||
|
||||
if(!rawBsVersion){ throw new Error("NOT_BS_FOLDER"); }
|
||||
|
||||
const destPath = await this.getPathNotAleardyExist(await this.localVersionService.getVersionPath(rawBsVersion));
|
||||
|
||||
await copy(path, destPath, {dereference: true});
|
||||
|
||||
return rawBsVersion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -168,12 +224,13 @@ export interface DownloadInfo {
|
||||
bsVersion: BSVersion,
|
||||
username: string,
|
||||
password?: string,
|
||||
stay?: boolean
|
||||
stay?: boolean,
|
||||
isVerification: boolean
|
||||
}
|
||||
|
||||
export interface DownloadEvent{
|
||||
type: DownloadEventType,
|
||||
data?: unknown,
|
||||
data?: unknown
|
||||
}
|
||||
|
||||
export type DownloadEventType = "[Password]" | "[Guard]" | "[2FA]" | "[Progress]" | "[Validated]" | "[Finished]" | "[AlreadyDownloading]" | "[Error]" | "[Warning]" | "[SteamID]" | "[Exit]" | "[NoInternet]";
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import path from "path";
|
||||
import { LaunchResult, LauchOption } from "shared/models/bs-launch";
|
||||
import { UtilsService } from "./utils.service";
|
||||
import { BS_EXECUTABLE, BS_APP_ID } from "../constants";
|
||||
import { BS_EXECUTABLE, BS_APP_ID, STEAMVR_APP_ID } from "../constants";
|
||||
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
|
||||
import { SteamService } from "./steam.service";
|
||||
import { BSLocalVersionService } from "./bs-local-version.service";
|
||||
import { OculusService } from "./oculus.service";
|
||||
import { pathExist } from "../helpers/fs.helpers";
|
||||
import { rename } from "fs/promises";
|
||||
import log from "electron-log";
|
||||
import { timer } from "rxjs";
|
||||
|
||||
export class BSLauncherService{
|
||||
|
||||
@@ -30,6 +34,23 @@ export class BSLauncherService{
|
||||
this.localVersionService = BSLocalVersionService.getInstance();
|
||||
}
|
||||
|
||||
private getSteamVRPath(): Promise<string>{
|
||||
return this.steamService.getGameFolder(STEAMVR_APP_ID, "SteamVR");
|
||||
}
|
||||
|
||||
private async backupSteamVR(): Promise<void>{
|
||||
const steamVrFolder = await this.getSteamVRPath();
|
||||
if(!await pathExist(steamVrFolder)){ return; }
|
||||
return rename(steamVrFolder, steamVrFolder + ".bak");
|
||||
}
|
||||
|
||||
public async restoreSteamVR(): Promise<void>{
|
||||
const steamVrFolder = await this.getSteamVRPath();
|
||||
const steamVrBackup = steamVrFolder + ".bak";
|
||||
if(!await pathExist(steamVrBackup)){ return; }
|
||||
return rename(steamVrFolder + ".bak", steamVrFolder);
|
||||
}
|
||||
|
||||
public isBsRunning(): boolean{
|
||||
return this.bsProcess?.connected || this.utilsService.taskRunning(BS_EXECUTABLE);
|
||||
}
|
||||
@@ -42,15 +63,43 @@ export class BSLauncherService{
|
||||
const cwd = await this.localVersionService.getVersionPath(launchOptions.version);
|
||||
const exePath = path.join(cwd, BS_EXECUTABLE);
|
||||
|
||||
if(!this.utilsService.pathExist(exePath)){ return "EXE_NOT_FINDED"; }
|
||||
if(!(await pathExist(exePath))){ return "EXE_NOT_FINDED"; }
|
||||
|
||||
const launchMods = [launchOptions.oculus && "-vrmode oculus", launchOptions.desktop && "fpfc", launchOptions.debug && "--verbose"];
|
||||
let launchArgs = [];
|
||||
|
||||
this.bsProcess = spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID}});
|
||||
if(!launchOptions.version.steam && !launchOptions.version.oculus){ launchArgs.push("--no-yeet"); }
|
||||
if(launchOptions.oculus){ launchArgs.push("-vrmode oculus"); }
|
||||
if(launchOptions.desktop){ launchArgs.push("fpfc"); }
|
||||
if(launchOptions.debug){ launchArgs.push("--verbose"); }
|
||||
if(launchOptions.additionalArgs){ launchArgs.push(...launchOptions.additionalArgs); }
|
||||
|
||||
this.bsProcess.on('message', msg => { /** EMIT HERE **/ });
|
||||
this.bsProcess.on('error', err => { /** EMIT HERE **/ });
|
||||
this.bsProcess.on('exit', code => this.utilsService.ipcSend("bs-launch.exit", {data: code, success: code === 0}));
|
||||
launchArgs = Array.from(new Set(launchArgs).values());
|
||||
|
||||
if(launchArgs.includes("fpfc")){
|
||||
await this.backupSteamVR().catch(e => {
|
||||
log.error(e);
|
||||
this.restoreSteamVR();
|
||||
}).finally(() => {
|
||||
setTimeout(() => this.restoreSteamVR(), 35_000);
|
||||
});
|
||||
await timer(2_000).toPromise();
|
||||
}
|
||||
else{
|
||||
await this.restoreSteamVR();
|
||||
}
|
||||
|
||||
if(launchOptions.debug){
|
||||
this.bsProcess = spawn(`\"${exePath}\"`, launchArgs, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID}, detached: true, windowsVerbatimArguments: true });
|
||||
}
|
||||
else{
|
||||
this.bsProcess = spawn(`\"${exePath}\"`, launchArgs, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID} });
|
||||
}
|
||||
|
||||
this.bsProcess.on('error', err => log.error(err));
|
||||
this.bsProcess.on('exit', code => {
|
||||
this.restoreSteamVR();
|
||||
this.utilsService.ipcSend("bs-launch.exit", {data: code, success: code === 0})
|
||||
});
|
||||
|
||||
return "LAUNCHED";
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { BSVersionLibService } from "./bs-version-lib.service";
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { BSVersion, PartialBSVersion } from 'shared/bs-version.interface';
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
import { SteamService } from "./steam.service";
|
||||
import { UtilsService } from "./utils.service";
|
||||
import { BS_APP_ID, OCULUS_BS_DIR } from "../constants";
|
||||
import path from "path";
|
||||
import { createInterface } from "readline";
|
||||
import { createReadStream } from "fs";
|
||||
import fs from "fs-extra";
|
||||
import { ConfigurationService } from "./configuration.service";
|
||||
@@ -14,6 +12,9 @@ import { BsmException } from "shared/models/bsm-exception.model";
|
||||
import log from "electron-log";
|
||||
import { OculusService } from "./oculus.service";
|
||||
import { DownloadLinkType } from "shared/models/mods";
|
||||
import sanitize from "sanitize-filename";
|
||||
import { deleteFolder, getFoldersInFolder, pathExist } from "../helpers/fs.helpers";
|
||||
import { FolderLinkerService } from "./folder-linker.service";
|
||||
|
||||
export class BSLocalVersionService{
|
||||
|
||||
@@ -22,46 +23,57 @@ export class BSLocalVersionService{
|
||||
private readonly CUSTOM_VERSIONS_KEY = "custom-versions";
|
||||
|
||||
private readonly installLocationService: InstallationLocationService;
|
||||
private readonly utilsService: UtilsService;
|
||||
private readonly steamService: SteamService;
|
||||
private readonly oculusService: OculusService;
|
||||
private readonly remoteVersionService: BSVersionLibService;
|
||||
private readonly configService: ConfigurationService;
|
||||
private readonly linker: FolderLinkerService;
|
||||
|
||||
public static getInstance(): BSLocalVersionService{
|
||||
if(!BSLocalVersionService.instance){ BSLocalVersionService.instance = new BSLocalVersionService(); }
|
||||
return BSLocalVersionService.instance;
|
||||
}
|
||||
|
||||
private constructor(){
|
||||
this.installLocationService = InstallationLocationService.getInstance();
|
||||
this.utilsService = UtilsService.getInstance();
|
||||
this.steamService = SteamService.getInstance();
|
||||
this.oculusService = OculusService.getInstance();
|
||||
this.remoteVersionService = BSVersionLibService.getInstance();
|
||||
this.configService = ConfigurationService.getInstance();
|
||||
}
|
||||
private constructor(){
|
||||
this.installLocationService = InstallationLocationService.getInstance();
|
||||
this.steamService = SteamService.getInstance();
|
||||
this.oculusService = OculusService.getInstance();
|
||||
this.remoteVersionService = BSVersionLibService.getInstance();
|
||||
this.configService = ConfigurationService.getInstance();
|
||||
this.linker = FolderLinkerService.getInstance();
|
||||
}
|
||||
|
||||
private async getVersionOfBSFolder(bsPath: string): Promise<string>{
|
||||
|
||||
|
||||
public async getVersionOfBSFolder(bsPath: string): Promise<PartialBSVersion>{
|
||||
const versionFilePath = path.join(bsPath, 'Beat Saber_Data', 'globalgamemanagers');
|
||||
if(!this.utilsService.pathExist(versionFilePath)){ return null; }
|
||||
if(!(await pathExist(versionFilePath))){ return null; }
|
||||
const versionsAvailable = await this.remoteVersionService.getAvailableVersions();
|
||||
return new Promise<string>(resolve => {
|
||||
const readLine = createInterface({ input: createReadStream(versionFilePath) });
|
||||
let findVersion: string = null;
|
||||
readLine.on('line', (line) => {
|
||||
return new Promise<PartialBSVersion>(resolve => {
|
||||
const stream = createReadStream(versionFilePath);
|
||||
let findVersion: PartialBSVersion = null;
|
||||
stream.on('data', (line) => {
|
||||
line = line.toString();
|
||||
for(const version of versionsAvailable){
|
||||
if(line.includes(version.BSVersion)){
|
||||
findVersion = version.BSVersion;
|
||||
readLine.close();
|
||||
findVersion = {BSVersion: version.BSVersion};
|
||||
if(findVersion.BSVersion !== path.basename(bsPath)){
|
||||
findVersion.name = path.basename(bsPath);
|
||||
}
|
||||
stream.close();
|
||||
stream.destroy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
readLine.on('close', () => {
|
||||
stream.on('end', () => {
|
||||
if(findVersion){ resolve(findVersion) }
|
||||
resolve(findVersion);
|
||||
});
|
||||
stream.on('close', () => {
|
||||
if(findVersion){ resolve(findVersion) }
|
||||
resolve(findVersion);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -92,11 +104,11 @@ export class BSLocalVersionService{
|
||||
}
|
||||
|
||||
private removeSpecialChar(seq: string): string{
|
||||
return seq.replace( /[<>:"\/\\|?*]+/g, '' );
|
||||
return sanitize(seq);
|
||||
}
|
||||
|
||||
public getVersionFolder(version: BSVersion){
|
||||
return version.name ? `${version.BSVersion}-${version.name}` : version.BSVersion;
|
||||
public getVersionFolder(version: BSVersion): string{
|
||||
return version.name ?? version.BSVersion;
|
||||
}
|
||||
|
||||
public getVersionType(version: BSVersion): DownloadLinkType{
|
||||
@@ -107,10 +119,11 @@ export class BSLocalVersionService{
|
||||
|
||||
private async getSteamVersion(): Promise<BSVersion>{
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
if(!steamBsFolder || !this.utilsService.pathExist(steamBsFolder)){ return null; }
|
||||
if(!steamBsFolder || !(await pathExist(steamBsFolder))){ return null; }
|
||||
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
|
||||
|
||||
if(!steamBsVersion){ return null; }
|
||||
const version = await this.remoteVersionService.getVersionDetails(steamBsVersion);
|
||||
const version = await this.remoteVersionService.getVersionDetails(steamBsVersion.BSVersion);
|
||||
if(!version){ return null; }
|
||||
return {...version, steam: true};
|
||||
}
|
||||
@@ -120,45 +133,52 @@ export class BSLocalVersionService{
|
||||
if(!oculusBsFolder){ return null; }
|
||||
const oculusBsVersion = await this.getVersionOfBSFolder(oculusBsFolder);
|
||||
if(!oculusBsVersion){ return null; }
|
||||
const version = await this.remoteVersionService.getVersionDetails(oculusBsVersion);
|
||||
const version = await this.remoteVersionService.getVersionDetails(oculusBsVersion.BSVersion);
|
||||
if(!version){ return null; }
|
||||
return {...version, oculus: true};
|
||||
}
|
||||
|
||||
public async getInstalledVersions(): Promise<BSVersion[]>{
|
||||
|
||||
const versions: BSVersion[] = [];
|
||||
const steamVersion = await this.getSteamVersion();
|
||||
if(steamVersion){ versions.push(steamVersion); }
|
||||
const oculusVersion = await this.getOculusVersion();
|
||||
if(oculusVersion){ versions.push(oculusVersion); }
|
||||
const versions: BSVersion[] = [];
|
||||
|
||||
if(!this.utilsService.pathExist(this.installLocationService.versionsDirectory)){ return versions }
|
||||
const steamVersion = await this.getSteamVersion();
|
||||
if(steamVersion){ versions.push(steamVersion); }
|
||||
|
||||
const folderInInstallation = this.utilsService.listDirsInDir(this.installLocationService.versionsDirectory);
|
||||
for(const f of folderInInstallation){
|
||||
log.info("try get version from folder", f);
|
||||
let version = await this.remoteVersionService.getVersionDetails(f);
|
||||
if(version){ version = this.getCustomVersions().find(v => v.BSVersion === version.BSVersion && v.name === version.name) ?? version; }
|
||||
else { version = this.getCustomVersions().find(v => {
|
||||
const [version, ...rest] = f.split("-");
|
||||
if(rest.length < 1){ return false; }
|
||||
const name = rest.join("-");
|
||||
return name === v.name && version === v.BSVersion;
|
||||
})
|
||||
}
|
||||
version && versions.push(version);
|
||||
};
|
||||
this.setCustomVersions(versions.filter(v => !!v.name || !!v.color));
|
||||
return versions;
|
||||
const oculusVersion = await this.getOculusVersion();
|
||||
if(oculusVersion){ versions.push(oculusVersion); }
|
||||
|
||||
if(!(await pathExist(this.installLocationService.versionsDirectory))){ return versions }
|
||||
|
||||
const folderInInstallation = await getFoldersInFolder(this.installLocationService.versionsDirectory);
|
||||
|
||||
for(const f of folderInInstallation){
|
||||
log.info("try get version from folder", f);
|
||||
const rawVersion = await this.getVersionOfBSFolder(f);
|
||||
if(!rawVersion){ continue; }
|
||||
const bsVersion = {...await this.remoteVersionService.getVersionDetails(rawVersion.BSVersion)};
|
||||
if(!bsVersion){ continue; }
|
||||
bsVersion.name = path.basename(f) !== bsVersion.BSVersion ? path.basename(f) : undefined;
|
||||
|
||||
const customVersion = this.getCustomVersions().find(custom => custom.BSVersion === bsVersion.BSVersion && custom.name === bsVersion.name);
|
||||
|
||||
if(customVersion){
|
||||
bsVersion.color = customVersion.color;
|
||||
}
|
||||
|
||||
versions.push(bsVersion);
|
||||
};
|
||||
this.setCustomVersions(versions.filter(v => !!v.color));
|
||||
|
||||
return versions;
|
||||
}
|
||||
|
||||
public async deleteVersion(version: BSVersion): Promise<boolean>{
|
||||
if(version.steam || version.oculus){ return false; }
|
||||
const versionFolder = await this.getVersionPath(version);
|
||||
if(!this.utilsService.pathExist(versionFolder)){ return true; }
|
||||
if(!(await pathExist(versionFolder))){ return true; }
|
||||
|
||||
return this.utilsService.deleteFolder(versionFolder)
|
||||
return deleteFolder(versionFolder)
|
||||
.then(() => { return true; })
|
||||
.catch(() => { return false; })
|
||||
}
|
||||
@@ -177,13 +197,14 @@ export class BSLocalVersionService{
|
||||
return editedVersion;
|
||||
}
|
||||
|
||||
if(this.utilsService.pathExist(newPath)){ throw {title: "VersionAlreadExist"} as BsmException; }
|
||||
if((await pathExist(newPath)) && newPath === oldPath){ throw {title: "VersionAlreadExist"} as BsmException; }
|
||||
|
||||
return rename(oldPath, newPath).then(() => {
|
||||
this.deleteCustomVersion(version);
|
||||
this.addCustomVersion(editedVersion);
|
||||
return editedVersion;
|
||||
}).catch((err: Error) => {
|
||||
log.error("edit version error", err, version, name, color);
|
||||
throw {title: "CantRename", error: err} as BsmException;
|
||||
});
|
||||
}
|
||||
@@ -198,18 +219,31 @@ export class BSLocalVersionService{
|
||||
if(originPath === newPath){
|
||||
this.deleteCustomVersion(version);
|
||||
this.addCustomVersion(cloneVersion);
|
||||
return cloneVersion;
|
||||
}
|
||||
|
||||
if(this.utilsService.pathExist(newPath)){ throw {title: "VersionAlreadExist"} as BsmException; }
|
||||
if(await pathExist(newPath)){ throw {title: "VersionAlreadExist"} as BsmException; }
|
||||
|
||||
return fs.copy(originPath, newPath, {dereference: true}).then(() => {
|
||||
this.addCustomVersion(cloneVersion);
|
||||
return cloneVersion;
|
||||
}).catch((err: Error) => {
|
||||
log.error("CLONE", err, version);
|
||||
log.error("clone version error", err, version, name, color);
|
||||
throw {title: "CantClone", error: err} as BsmException
|
||||
})
|
||||
}
|
||||
|
||||
public async getLinkedFolders(version: BSVersion): Promise<string[]>{
|
||||
const versionPath = await this.getVersionPath(version);
|
||||
const [rootFolders, beatSaberDataFolders] = await Promise.all([
|
||||
getFoldersInFolder(versionPath),
|
||||
getFoldersInFolder(path.join(versionPath, "Beat Saber_Data"))
|
||||
]);
|
||||
|
||||
const linkedFolder = Promise.all([...rootFolders, ...beatSaberDataFolders].map(async folder => {
|
||||
if(!(await this.linker.isFolderSymlink(folder))){ return null; }
|
||||
return folder;
|
||||
}));
|
||||
|
||||
return (await linkedFolder).filter(folder => folder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { get } from 'https'
|
||||
import { UtilsService } from './utils.service';
|
||||
import path from 'path';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { RequestService } from "./request.service"
|
||||
import isOnline from 'is-online';
|
||||
import { readJSON } from 'fs-extra';
|
||||
|
||||
export class BSVersionLibService{
|
||||
|
||||
@@ -35,8 +35,7 @@ export class BSVersionLibService{
|
||||
|
||||
private async getLocalVersions(): Promise<BSVersion[]>{
|
||||
const localVersionsPath = path.join(this.utilsService.getAssestsJsonsPath(), this.VERSIONS_FILE);
|
||||
const rawVersion = (await this.utilsService.readFileAsync(localVersionsPath)).toString();
|
||||
return JSON.parse(rawVersion);
|
||||
return readJSON(localVersionsPath);
|
||||
}
|
||||
|
||||
private async updateLocalVersions(versions: BSVersion[]): Promise<void>{
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
import log from "electron-log";
|
||||
import { deleteFolder, ensureFolderExist, moveFolderContent, pathExist, unlinkPath } from "../helpers/fs.helpers";
|
||||
import { lstat, symlink } from "fs/promises";
|
||||
import path from "path";
|
||||
import { copy } from "fs-extra";
|
||||
|
||||
export class FolderLinkerService {
|
||||
|
||||
private static instance: FolderLinkerService;
|
||||
|
||||
public static getInstance(): FolderLinkerService {
|
||||
if (!FolderLinkerService.instance) {
|
||||
FolderLinkerService.instance = new FolderLinkerService();
|
||||
}
|
||||
return FolderLinkerService.instance;
|
||||
}
|
||||
|
||||
private readonly installLocationService = InstallationLocationService.getInstance();
|
||||
|
||||
private readonly sharedFolder: string;
|
||||
|
||||
private constructor(){
|
||||
this.installLocationService = InstallationLocationService.getInstance();
|
||||
|
||||
this.sharedFolder = this.installLocationService.sharedContentPath;
|
||||
}
|
||||
|
||||
private getSharedFolder(folderPath: string, intermediateFolder?: string): string {
|
||||
return path.join(this.sharedFolder, intermediateFolder ?? "", path.basename(folderPath));
|
||||
}
|
||||
|
||||
private getBackupFolder(folderPath: string): string {
|
||||
return folderPath + "_backup";
|
||||
}
|
||||
|
||||
private async backupFolder(folderPath: string): Promise<void> {
|
||||
if(!await pathExist(folderPath)){ return; }
|
||||
return copy(folderPath, this.getBackupFolder(folderPath), { overwrite: true, errorOnExist: false });
|
||||
}
|
||||
|
||||
private async restoreFolder(folderPath: string): Promise<void> {
|
||||
if(!await pathExist( this.getBackupFolder(folderPath) )){ return; }
|
||||
return copy(this.getBackupFolder(folderPath), folderPath, { overwrite: true, errorOnExist: false }).then(() => {
|
||||
return deleteFolder(this.getBackupFolder(folderPath));
|
||||
});
|
||||
}
|
||||
|
||||
public async linkFolder(folderPath: string, options?: LinkOptions): Promise<void> {
|
||||
|
||||
if(await this.isFolderSymlink(folderPath)){ return; }
|
||||
|
||||
const sharedPath = this.getSharedFolder(folderPath, options?.intermediateFolder);
|
||||
|
||||
await ensureFolderExist(folderPath);
|
||||
await ensureFolderExist(sharedPath);
|
||||
|
||||
if(options?.backup === true){
|
||||
await this.backupFolder(folderPath);
|
||||
}
|
||||
|
||||
if(options?.keepContents !== false){
|
||||
await moveFolderContent(folderPath, sharedPath).toPromise();
|
||||
}
|
||||
|
||||
await deleteFolder(folderPath);
|
||||
|
||||
return symlink(sharedPath, folderPath, "junction");
|
||||
}
|
||||
|
||||
public async unlinkFolder(folderPath: string, options?: LinkOptions): Promise<void> {
|
||||
|
||||
if(!(await this.isFolderSymlink(folderPath))){ return; }
|
||||
await unlinkPath(folderPath);
|
||||
|
||||
const sharedPath = this.getSharedFolder(folderPath, options?.intermediateFolder);
|
||||
|
||||
await ensureFolderExist(folderPath);
|
||||
|
||||
if(options?.backup === true){
|
||||
return this.restoreFolder(folderPath);
|
||||
}
|
||||
|
||||
if(options?.keepContents === false){ return; }
|
||||
|
||||
await ensureFolderExist(sharedPath);
|
||||
|
||||
return copy(sharedPath, folderPath, { errorOnExist: false, recursive: true });
|
||||
}
|
||||
|
||||
public async isFolderSymlink(folder: string): Promise<boolean> {
|
||||
try{
|
||||
if(!(await pathExist(folder))){ return false; }
|
||||
return lstat(folder).then(stat => stat.isSymbolicLink());
|
||||
}
|
||||
catch(e){
|
||||
log.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface LinkOptions {
|
||||
keepContents?: boolean,
|
||||
intermediateFolder?: string,
|
||||
backup?: boolean
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import path from "path";
|
||||
import { UtilsService } from "./utils.service";
|
||||
import fs from 'fs-extra';
|
||||
import log from "electron-log";
|
||||
import { app } from "electron";
|
||||
import { BsmException } from "shared/models/bsm-exception.model";
|
||||
import ElectronStore from "electron-store";
|
||||
import { ensureFolderExist, pathExist } from "../helpers/fs.helpers";
|
||||
|
||||
export class InstallationLocationService {
|
||||
|
||||
@@ -19,10 +19,8 @@ export class InstallationLocationService {
|
||||
private readonly VERSIONS_FOLDER = "BSInstances";
|
||||
|
||||
private readonly SHARED_CONTENT_FOLDER = "SharedContent";
|
||||
private readonly SHARED_MAPS_FOLDER = "SharedMaps";
|
||||
|
||||
private readonly STORE_INSTALLATION_PATH_KEY = "installation-folder";
|
||||
private readonly utilsService: UtilsService;
|
||||
|
||||
private readonly installPathConfig: ElectronStore;
|
||||
private readonly updateListeners: Set<Listener> = new Set();
|
||||
@@ -31,7 +29,6 @@ export class InstallationLocationService {
|
||||
|
||||
private constructor(){
|
||||
this.installPathConfig = new ElectronStore({watch: true});
|
||||
this.utilsService = UtilsService.getInstance();
|
||||
this.initInstallationLocation();
|
||||
|
||||
this.installPathConfig.onDidChange(this.STORE_INSTALLATION_PATH_KEY, () => {
|
||||
@@ -50,8 +47,8 @@ export class InstallationLocationService {
|
||||
public setInstallationDirectory(newDir: string): Promise<string>{
|
||||
const oldDir = this.installationDirectory;
|
||||
const newDest = path.join(newDir, this.INSTALLATION_FOLDER);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
if(!this.utilsService.pathExist(oldDir)){ this.utilsService.createFolderIfNotExist(oldDir); }
|
||||
return new Promise<string>(async (resolve, reject) => {
|
||||
if(!(await pathExist(oldDir))){ ensureFolderExist(oldDir); }
|
||||
fs.move(oldDir, newDest, { overwrite: true }).then(() => {
|
||||
this._installationDirectory = newDir;
|
||||
this.installPathConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
|
||||
@@ -72,7 +69,6 @@ export class InstallationLocationService {
|
||||
public get versionsDirectory(): string { return path.join(this.installationDirectory, this.VERSIONS_FOLDER); }
|
||||
|
||||
public get sharedContentPath(): string { return path.join(this.installationDirectory, this.SHARED_CONTENT_FOLDER); }
|
||||
public get sharedMapsPath(): string { return path.join(this.sharedContentPath, this.SHARED_MAPS_FOLDER); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { ipcMain } from "electron";
|
||||
import { Observable } from "rxjs";
|
||||
import { IpcChannel, IpcCompleteChannel, IpcErrorChannel } from "shared/models/ipc/ipc-response.interface";
|
||||
import { AppWindow } from "shared/models/window-manager/app-window.model";
|
||||
import { WindowManagerService } from "./window-manager.service";
|
||||
import { IpcReplier } from "shared/models/ipc/ipc-request.interface";
|
||||
import log from "electron-log";
|
||||
|
||||
export class IpcService {
|
||||
|
||||
private static instance: IpcService;
|
||||
|
||||
public static getInstance(): IpcService {
|
||||
if (!IpcService.instance) { IpcService.instance = new IpcService(); }
|
||||
return IpcService.instance;
|
||||
}
|
||||
|
||||
private readonly windows: WindowManagerService;
|
||||
|
||||
private constructor() {
|
||||
this.windows = WindowManagerService.getInstance();
|
||||
}
|
||||
|
||||
private getErrorChannel(channel: IpcChannel): IpcErrorChannel {
|
||||
return `${channel}_error`;
|
||||
}
|
||||
|
||||
private getCompleteChannel(channel: IpcChannel): IpcCompleteChannel {
|
||||
return `${channel}_complete`;
|
||||
}
|
||||
|
||||
private buildProxyListener<T>(listener: (req: IpcRequest<T>, replier: IpcReplier) => void) {
|
||||
|
||||
return (event: Electron.IpcMainEvent, req: IpcRequest<T>) => {
|
||||
const window = this.windows.getAppWindowFromWebContents(event.sender);
|
||||
const replier = (data: Observable<unknown>) => this.connectStream(req.responceChannel, window, data);
|
||||
listener(req, replier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public send<T>(channel: IpcChannel, window: AppWindow, response?: T|Error): void{
|
||||
this.windows.getWindow(window)?.webContents?.send(channel, response);
|
||||
}
|
||||
|
||||
public connectStream(channel: IpcChannel, window: AppWindow, observable: Observable<unknown>): void{
|
||||
observable.subscribe(data => {
|
||||
this.send(channel, window, data);
|
||||
}, error => {
|
||||
log.error(error);
|
||||
this.send(this.getErrorChannel(channel), window, error);
|
||||
}, () => {
|
||||
this.send(this.getCompleteChannel(channel), window);
|
||||
});
|
||||
}
|
||||
|
||||
public on<T>(channel: IpcChannel, listener: (req: IpcRequest<T>, replier: IpcReplier) => void): void{
|
||||
ipcMain.on(channel, this.buildProxyListener(listener));
|
||||
}
|
||||
|
||||
public once<T>(channel: IpcChannel, listener: (req: IpcRequest<T>, replier: IpcReplier) => void): void{
|
||||
ipcMain.once(channel, this.buildProxyListener(listener));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { RequestService } from "../request.service";
|
||||
import { spawn } from "child_process";
|
||||
import { BS_EXECUTABLE } from "../../constants";
|
||||
import log from "electron-log";
|
||||
import { deleteFolder, ensureFolderExist, pathExist, unlinkPath } from "../../helpers/fs.helpers";
|
||||
|
||||
export class BsModsManagerService {
|
||||
|
||||
@@ -60,7 +61,7 @@ export class BsModsManagerService {
|
||||
private async getModsInDir(version: BSVersion, modsDir: ModsInstallFolder): Promise<Mod[]>{
|
||||
const bsPath = await this.bsLocalService.getVersionPath(version);
|
||||
const modsPath = path.join(bsPath, modsDir);
|
||||
if(!this.utilsService.pathExist(modsPath)){ return []; }
|
||||
if(!(await pathExist(modsPath))){ return []; }
|
||||
const files = fs.readdirSync(modsPath);
|
||||
const promises = files.map(f => {
|
||||
return (async() => {
|
||||
@@ -89,7 +90,7 @@ export class BsModsManagerService {
|
||||
private async getBsipaInstalled(version: BSVersion): Promise<Mod>{
|
||||
const bsPath = await this.bsLocalService.getVersionPath(version);
|
||||
const injectorPath = path.join(bsPath, "Beat Saber_Data", "Managed", "IPA.Injector.dll");
|
||||
if(!this.utilsService.pathExist(injectorPath)){ return undefined; }
|
||||
if(!(await pathExist(injectorPath))){ return undefined; }
|
||||
const injectorMd5 = await md5File(injectorPath);
|
||||
return this.getIpaFromHash(injectorMd5);
|
||||
}
|
||||
@@ -98,7 +99,7 @@ export class BsModsManagerService {
|
||||
zipUrl = path.join(this.beatModsApi.BEAT_MODS_URL, zipUrl);
|
||||
const fileName = path.basename(zipUrl);
|
||||
const tempPath = this.utilsService.getTempPath();
|
||||
this.utilsService.createFolderIfNotExist(this.utilsService.getTempPath());
|
||||
await ensureFolderExist(this.utilsService.getTempPath());
|
||||
const dest = path.join(tempPath, fileName);
|
||||
|
||||
const zipPath = await this.requestService.downloadFile(zipUrl, dest);
|
||||
@@ -111,7 +112,7 @@ export class BsModsManagerService {
|
||||
const versionPath = await this.bsLocalService.getVersionPath(version);
|
||||
const ipaPath = path.join(versionPath, "IPA.exe");
|
||||
const bsExePath = path.join(versionPath, BS_EXECUTABLE);
|
||||
if(!this.utilsService.pathExist(ipaPath) || !this.utilsService.pathExist(bsExePath)){ return false; }
|
||||
if(!(await pathExist(ipaPath)) || !(await pathExist(bsExePath))){ return false; }
|
||||
|
||||
return new Promise<boolean>(resolve => {
|
||||
const processIPA = spawn(`start /wait /min "" "${ipaPath}" ${args.join(" ")}`, {cwd: versionPath, detached: true, shell: true});
|
||||
@@ -163,7 +164,7 @@ export class BsModsManagerService {
|
||||
const extracted = await zip.extract(null, destDir).then(() => true).catch(err => {log.error(err); return false});
|
||||
|
||||
await zip.close();
|
||||
await this.utilsService.unlinkIfExist(zipPath);
|
||||
await unlinkPath(zipPath);
|
||||
|
||||
const res = isBSIPA ? (extracted && (await this.executeBSIPA(version, ["-n"]))) : extracted;
|
||||
|
||||
@@ -194,8 +195,8 @@ export class BsModsManagerService {
|
||||
const download = this.getModDownload(mod, version);
|
||||
|
||||
const verionPath = await this.bsLocalService.getVersionPath(version);
|
||||
const hasIPAExe = this.utilsService.pathExist(path.join(verionPath, "IPA.exe"));
|
||||
const hasIPADir = this.utilsService.pathExist(path.join(verionPath, "IPA"));
|
||||
const hasIPAExe = await pathExist(path.join(verionPath, "IPA.exe"));
|
||||
const hasIPADir = await pathExist(path.join(verionPath, "IPA"));
|
||||
|
||||
if(!hasIPADir || !hasIPAExe){ return; }
|
||||
|
||||
@@ -203,7 +204,7 @@ export class BsModsManagerService {
|
||||
|
||||
const promises = download.hashMd5.map(files => {
|
||||
const file = files.file.replaceAll("IPA/", "").replaceAll("Data", "Beat Saber_Data");
|
||||
return this.utilsService.unlinkIfExist(path.join(verionPath, file));
|
||||
return unlinkPath(path.join(verionPath, file));
|
||||
})
|
||||
|
||||
await Promise.all(promises);
|
||||
@@ -220,8 +221,10 @@ export class BsModsManagerService {
|
||||
const versionPath = await this.bsLocalService.getVersionPath(version);
|
||||
|
||||
const promises = download.hashMd5.map(async files => {
|
||||
this.utilsService.unlinkIfExist(path.join(versionPath, files.file));
|
||||
this.utilsService.unlinkIfExist(path.join(versionPath, "IPA", "Pending", files.file));
|
||||
return Promise.all([
|
||||
unlinkPath(path.join(versionPath, files.file)),
|
||||
unlinkPath(path.join(versionPath, "IPA", "Pending", files.file))
|
||||
]);
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
@@ -306,9 +309,9 @@ export class BsModsManagerService {
|
||||
|
||||
const versionPath = await this.bsLocalService.getVersionPath(version);
|
||||
|
||||
this.utilsService.rmDirIfExist(path.join(versionPath, ModsInstallFolder.PLUGINS));
|
||||
this.utilsService.rmDirIfExist(path.join(versionPath, ModsInstallFolder.LIBS));
|
||||
this.utilsService.rmDirIfExist(path.join(versionPath, ModsInstallFolder.IPA));
|
||||
await deleteFolder(path.join(versionPath, ModsInstallFolder.PLUGINS));
|
||||
await deleteFolder(path.join(versionPath, ModsInstallFolder.LIBS));
|
||||
await deleteFolder(path.join(versionPath, ModsInstallFolder.IPA));
|
||||
|
||||
path.resolve
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { UtilsService } from "./utils.service";
|
||||
import regedit from 'regedit'
|
||||
import path from "path";
|
||||
import { pathExist } from "../helpers/fs.helpers";
|
||||
|
||||
export class OculusService {
|
||||
|
||||
@@ -50,11 +51,14 @@ export class OculusService {
|
||||
public async getGameFolder(gameFolder: string): Promise<string>{
|
||||
|
||||
const libsFolders = await this.getOculusLibsPath();
|
||||
|
||||
if(!libsFolders){ return null; }
|
||||
|
||||
const rootLibDir = "Software"
|
||||
|
||||
for(const lib of libsFolders){
|
||||
const gameFullPath = path.join(lib, rootLibDir, gameFolder);
|
||||
if(this.utils.pathExist(gameFullPath)){ return gameFullPath; }
|
||||
if(await pathExist(gameFullPath)){ return gameFullPath; }
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -4,6 +4,8 @@ import path from "path";
|
||||
import { parse } from "@node-steam/vdf";
|
||||
import { readFile } from "fs/promises";
|
||||
import { spawn } from "child_process";
|
||||
import { pathExist } from "../helpers/fs.helpers";
|
||||
import log from "electron-log";
|
||||
|
||||
export class SteamService{
|
||||
|
||||
@@ -46,21 +48,27 @@ export class SteamService{
|
||||
}
|
||||
|
||||
public async getGameFolder(gameId: string, gameFolder?: string): Promise<string>{
|
||||
const steamPath = await this.getSteamPath();
|
||||
try{
|
||||
const steamPath = await this.getSteamPath();
|
||||
|
||||
let libraryFolders: any = path.join(steamPath, 'steamapps', 'libraryfolders.vdf');
|
||||
let libraryFolders: any = path.join(steamPath, 'steamapps', 'libraryfolders.vdf');
|
||||
|
||||
if(!this.utils.pathExist(libraryFolders)){ return null; }
|
||||
libraryFolders = parse(await readFile(libraryFolders, {encoding: 'utf-8'}));
|
||||
if(!(await pathExist(libraryFolders))){ return null; }
|
||||
libraryFolders = parse(await readFile(libraryFolders, {encoding: 'utf-8'}));
|
||||
|
||||
if(!libraryFolders.libraryfolders){ return null; }
|
||||
libraryFolders = libraryFolders.libraryfolders
|
||||
if(!libraryFolders.libraryfolders){ return null; }
|
||||
libraryFolders = libraryFolders.libraryfolders
|
||||
|
||||
for(const libKey in Object.keys(libraryFolders)){
|
||||
if(!libraryFolders[libKey] || !libraryFolders[libKey]["apps"]){ continue; }
|
||||
if(libraryFolders[libKey]["apps"][gameId]){ return path.join(libraryFolders[libKey]["path"], "steamapps", "common", gameFolder); };
|
||||
for(const libKey in Object.keys(libraryFolders)){
|
||||
if(!libraryFolders[libKey] || !libraryFolders[libKey]["apps"]){ continue; }
|
||||
if(libraryFolders[libKey]["apps"][gameId] != null){ return path.join(libraryFolders[libKey]["path"], "steamapps", "common", gameFolder); };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch(e){
|
||||
log.error(e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public openSteam(): Promise<boolean>{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { writeFileSync } from "fs";
|
||||
import { readJSON } from "fs-extra";
|
||||
import { get } from "https";
|
||||
import isOnline from "is-online";
|
||||
import path from "path";
|
||||
@@ -43,8 +44,7 @@ export class SupportersService {
|
||||
|
||||
private async getLocalSupporters(): Promise<Supporter[]>{
|
||||
const patreonsPath = path.join(this.utilsService.getAssestsJsonsPath(), this.PATREONS_FILE);
|
||||
const rawPatreons = (await this.utilsService.readFileAsync(patreonsPath)).toString();
|
||||
return JSON.parse(rawPatreons);
|
||||
return readJSON(patreonsPath);
|
||||
}
|
||||
|
||||
private async loadSupporters(): Promise<Supporter[]>{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { splitIntoChunk } from "../../../helpers/array-tools";
|
||||
import { splitIntoChunk } from "../../../helpers/array.helpers";
|
||||
import { BsvMapDetail } from "shared/models/maps";
|
||||
import { BsvPlaylist, SearchParams } from "shared/models/maps/beat-saver.model";
|
||||
import { BeatSaverApiService } from "./beat-saver-api.service";
|
||||
@@ -32,8 +32,7 @@ export class BeatSaverService {
|
||||
return res;
|
||||
}, [] as BsvMapDetail[]);
|
||||
|
||||
for(const hashs of chunkHash){
|
||||
|
||||
await Promise.allSettled(chunkHash.map(async hashs => {
|
||||
const res = await this.bsaverApi.getMapsDetailsByHashs(hashs);
|
||||
|
||||
if(res.status === 200){
|
||||
@@ -42,7 +41,7 @@ export class BeatSaverService {
|
||||
this.cachedMapsDetails.set(detail.versions.at(0).hash.toLowerCase(), detail);
|
||||
});
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return mapDetails;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
import { existsSync, mkdirSync, readdirSync, readFile, rmSync } from "fs";
|
||||
import { moveSync } from "fs-extra"
|
||||
import { spawnSync } from "child_process";
|
||||
import { homedir } from "os";
|
||||
import path from "path";
|
||||
import { app, BrowserWindow } from "electron";
|
||||
import { rm, unlink } from "fs/promises";
|
||||
import { IpcResponse } from "shared/models/ipc";
|
||||
import log from "electron-log";
|
||||
import { AppWindow } from "shared/models/window-manager/app-window.model";
|
||||
|
||||
|
||||
// TODO : REFACTOR
|
||||
|
||||
export class UtilsService{
|
||||
|
||||
private static instance: UtilsService;
|
||||
|
||||
private assetsPath: string = '';
|
||||
private assetsPath: string = app.isPackaged ? path.join(process.resourcesPath, 'assets') : path.join(__dirname, '../../../assets');
|
||||
|
||||
private windows: Map<AppWindow, BrowserWindow> = new Map<AppWindow, BrowserWindow>();
|
||||
|
||||
@@ -36,69 +33,14 @@ export class UtilsService{
|
||||
public setMainWindows(windows: Map<AppWindow, BrowserWindow>){ this.windows = windows; }
|
||||
public getMainWindows(win: AppWindow){ return this.windows.get(win); }
|
||||
|
||||
public pathExist(path: string): boolean{ return existsSync(path); }
|
||||
|
||||
public createFolderIfNotExist(path: string): void{
|
||||
if(!this.pathExist(path)){ mkdirSync(path, {recursive: true}); }
|
||||
}
|
||||
|
||||
public async unlinkIfExist(pathToFile: string): Promise<void>{
|
||||
if(!this.pathExist(pathToFile)){ return }
|
||||
return unlink(pathToFile);
|
||||
}
|
||||
|
||||
public async rmDirIfExist(path: string): Promise<void>{
|
||||
if(!this.pathExist(path)){ return; }
|
||||
return rm(path, {recursive: true, force: true});
|
||||
}
|
||||
|
||||
public taskRunning(task: string): boolean{
|
||||
const tasks = spawnSync('tasklist').stdout.toString();
|
||||
return tasks.includes(task);
|
||||
}
|
||||
|
||||
public getUserFolder(){ return homedir(); }
|
||||
|
||||
public getUserDocumentsFolder(): string{
|
||||
return path.join(this.getUserFolder(), 'Documents');
|
||||
}
|
||||
|
||||
public readFileAsync(path: string){
|
||||
return new Promise<Buffer>((resolve, reject) => {
|
||||
readFile(path, (err, data) => {
|
||||
if(err){ reject(err); }
|
||||
else{ resolve(data); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public listDirsInDir(dirPath: string, fullPath = false): string[]{
|
||||
let files = readdirSync(dirPath, { withFileTypes:true});
|
||||
files = files.filter(f => f.isDirectory())
|
||||
return files.map(f => fullPath ? path.join(dirPath, f.name) : f.name);
|
||||
}
|
||||
|
||||
public async deleteFolder(folderPath: string): Promise<void>{
|
||||
const folderExist = this.pathExist(folderPath);
|
||||
if(!folderExist){ return; }
|
||||
return rmSync(folderPath, {recursive: true});
|
||||
}
|
||||
|
||||
public async moveDirContent(src: string, dest: string, overwrite = false): Promise<void>{
|
||||
const [srcExist, destExist] = await Promise.all([this.pathExist(src), this.pathExist(dest)]);
|
||||
if(!srcExist){ return; }
|
||||
if(!destExist){ await this.createFolderIfNotExist(dest); }
|
||||
readdirSync(src, {encoding: "utf-8"}).forEach(file => {
|
||||
const srcFullPath = path.join(src, file);
|
||||
const destFullPath = path.join(dest, file);
|
||||
if(!overwrite && this.pathExist(destFullPath)){ return; }
|
||||
moveSync(srcFullPath, destFullPath, {overwrite});
|
||||
});
|
||||
}
|
||||
|
||||
public ipcSend<T = any>(channel: string, response: IpcResponse<T>): void{
|
||||
try {
|
||||
Array.from(this.windows.values()).forEach(window => window.webContents.send(channel, response));
|
||||
Array.from(this.windows.values()).forEach(window => window?.webContents?.send(channel, response));
|
||||
} catch (error) {
|
||||
log.error(error);
|
||||
}
|
||||
|
||||
@@ -75,8 +75,12 @@ export class WindowManagerService{
|
||||
});
|
||||
}
|
||||
|
||||
public getWindows(window: AppWindow): BrowserWindow{
|
||||
public getWindow(window: AppWindow): BrowserWindow{
|
||||
return this.windows.get(window);
|
||||
}
|
||||
|
||||
public getAppWindowFromWebContents(sender: Electron.WebContents): AppWindow{
|
||||
return Array.from(this.windows.entries()).find(([key, value]) => value.webContents.id === sender.id)[0];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import { BsmImage } from "../shared/bsm-image.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { BsmIcon } from "../svgs/bsm-icon.component";
|
||||
import { LinkOpenerService } from 'renderer/services/link-opener.service';
|
||||
import { motion } from 'framer-motion';
|
||||
import { GlowEffect } from '../shared/glow-effect.component';
|
||||
|
||||
export const AvailableVersionItem = memo(function AvailableVersionItem(props: {version: BSVersion}) {
|
||||
|
||||
@@ -15,6 +17,7 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
|
||||
const linkOpener = LinkOpenerService.getInstance();
|
||||
|
||||
const [selected, setSelected] = useState(false);
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const t = useTranslation();
|
||||
|
||||
const formatedDate = (() => { return dateFormat(+props.version.ReleaseDate*1000, "ddd. d mmm yyyy"); })()
|
||||
@@ -38,8 +41,8 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<li className="group relative w-72 h-60 transition-transform active:scale-[.98]" onClick={toggleSelect}>
|
||||
<span className={`absolute glow-on-hover group-hover:opacity-100 ${selected && "!opacity-100"}`}/>
|
||||
<motion.li className="group relative w-72 h-60 transition-transform active:scale-[.98]" onClick={toggleSelect} onHoverStart={() => setHovered(true)} onHoverEnd={() => setHovered(false)}>
|
||||
<GlowEffect visible={hovered || selected} className="absolute"/>
|
||||
<div className={`relative flex flex-col overflow-hidden rounded-md w-72 h-60 cursor-pointer group-hover:shadow-none duration-300 bg-light-main-color-2 dark:bg-main-color-2 ${!selected && "shadow-lg shadow-gray-900"}`}>
|
||||
<BsmImage image={props.version.ReleaseImg ? props.version.ReleaseImg : defaultImage} errorImage={defaultImage} placeholder={defaultImage} className="absolute top-0 right-0 w-full h-full opacity-40 blur-xl object-cover" loading="lazy"/>
|
||||
<BsmImage image={props.version.ReleaseImg ? props.version.ReleaseImg : defaultImage} errorImage={defaultImage} placeholder={defaultImage} className="bg-black w-full h-3/4 object-cover" loading="lazy"/>
|
||||
@@ -56,6 +59,6 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</motion.li>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { useEffect, useState } from "react"
|
||||
import { BSVersionManagerService } from "renderer/services/bs-version-manager.service";
|
||||
import { filter, take } from "rxjs/operators";
|
||||
import { filter } from "rxjs/operators";
|
||||
import { AvailableVersionItem } from "./available-version-item.component";
|
||||
|
||||
export function AvailableVersionsSlide(props: {year: string}) {
|
||||
@@ -11,7 +11,7 @@ export function AvailableVersionsSlide(props: {year: string}) {
|
||||
const versionsService = BSVersionManagerService.getInstance();
|
||||
|
||||
useEffect(() => {
|
||||
versionsService.availableVersions$.pipe(filter(versions => !!versions?.length), take(1)).subscribe(() => {
|
||||
versionsService.availableVersions$.pipe(filter(versions => !!versions?.length)).subscribe(() => {
|
||||
setAvailableVersions(versionsService.getAvaibleVersionsOfYear(props.year));
|
||||
});
|
||||
}, [])
|
||||
|
||||
+14
-14
@@ -1,29 +1,29 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { BSVersionManagerService } from "../../services/bs-version-manager.service";
|
||||
import { AvailableVersionsSlide } from "./available-versions-slide.component";
|
||||
import { filter, take } from "rxjs/operators";
|
||||
import { filter} from "rxjs/operators";
|
||||
import { TabNavBar } from "../shared/tab-nav-bar.component";
|
||||
|
||||
export function AvailableVersionsSlider() {
|
||||
|
||||
const [availableYears, setAvailableYears] = useState([]);
|
||||
const [yearIndex, setYearIndex] = useState(0);
|
||||
const versionManagerService = BSVersionManagerService.getInstance();
|
||||
|
||||
const versionManagerService = BSVersionManagerService.getInstance();
|
||||
const [availableYears, setAvailableYears] = useState([]);
|
||||
const [yearIndex, setYearIndex] = useState(0);
|
||||
|
||||
const setSelectedYear = (index: number) => {
|
||||
setYearIndex(index);
|
||||
}
|
||||
const setSelectedYear = (index: number) => {
|
||||
setYearIndex(index);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
versionManagerService.availableVersions$.pipe(filter(versions => !!versions?.length), take(1)).subscribe(() => {
|
||||
setAvailableYears(versionManagerService.getAvailableYears());
|
||||
});
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
versionManagerService.availableVersions$.pipe(filter(versions => !!versions?.length)).subscribe(() => {
|
||||
setAvailableYears(versionManagerService.getAvailableYears());
|
||||
});
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="w-full h-fit max-h-full flex flex-col items-center grow min-h-0">
|
||||
<TabNavBar className="mb-3" tabIndex={yearIndex} tabsText={availableYears} onTabChange={setSelectedYear}/>
|
||||
<div className="w-full h-fit max-h-full flex flex-col items-center grow min-h-0 gap-3">
|
||||
<TabNavBar tabIndex={yearIndex} tabsText={availableYears} onTabChange={setSelectedYear}/>
|
||||
<ol className="w-full min-h-0 flex transition-transform duration-300" style={{transform: `translate(${-(yearIndex * 100)}%, 0)`}}>
|
||||
{ availableYears.map(year =>
|
||||
<AvailableVersionsSlide key={year} year={year}/>
|
||||
|
||||
@@ -12,6 +12,9 @@ import { MAP_SPECIFICITIES } from "renderer/partials/maps/map-general/map-specif
|
||||
import { MAP_REQUIREMENTS } from "renderer/partials/maps/map-requirements/map-requirements"
|
||||
import { MAP_DIFFICULTIES_COLORS } from "renderer/partials/maps/map-difficulties/map-difficulties-colors"
|
||||
import { BsmButton } from "../shared/bsm-button.component"
|
||||
import equal from "fast-deep-equal/es6";
|
||||
import clone from "rfdc";
|
||||
import { GlowEffect } from "../shared/glow-effect.component"
|
||||
|
||||
export type Props = {
|
||||
className?: string,
|
||||
@@ -28,6 +31,7 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
const t = useTranslation();
|
||||
|
||||
const [haveChanged, setHaveChanged] = useState(false);
|
||||
const [firstFilter,] = useState(clone()(filter));
|
||||
const firstRun = useRef(true);
|
||||
|
||||
const MIN_NPS = 0;
|
||||
@@ -47,7 +51,7 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
firstRun.current = false;
|
||||
return;
|
||||
}
|
||||
setHaveChanged(() => true);
|
||||
setHaveChanged(() => !equal(filter, firstFilter));
|
||||
}, [filter])
|
||||
|
||||
|
||||
@@ -89,6 +93,9 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
if(max === MAX_NPS){
|
||||
delete newFilter["maxNps"];
|
||||
}
|
||||
if(min === MIN_NPS){
|
||||
delete newFilter["minNps"];
|
||||
}
|
||||
onChange(newFilter);
|
||||
}
|
||||
|
||||
@@ -97,6 +104,9 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
if(max === MAX_DURATION){
|
||||
delete newFilter["maxDuration"];
|
||||
}
|
||||
if(min === MIN_DURATION){
|
||||
delete newFilter["minDuration"];
|
||||
}
|
||||
onChange(newFilter);
|
||||
}
|
||||
|
||||
@@ -116,11 +126,17 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
enabledTags.add(tag);
|
||||
}
|
||||
|
||||
onChange({
|
||||
...filter,
|
||||
enabledTags,
|
||||
excludedTags
|
||||
});
|
||||
const newFilter = {...filter, enabledTags, excludedTags};
|
||||
|
||||
if(newFilter.enabledTags.size === 0){
|
||||
delete newFilter["enabledTags"];
|
||||
}
|
||||
|
||||
if(newFilter.excludedTags.size === 0){
|
||||
delete newFilter["excludedTags"];
|
||||
}
|
||||
|
||||
onChange(newFilter);
|
||||
|
||||
}
|
||||
|
||||
@@ -197,8 +213,8 @@ export function FilterPanel({className, ref, playlist = false, filter, onChange,
|
||||
</div>
|
||||
{onApply && (
|
||||
<div className="inline float-right relative w-fit h-fit mt-2">
|
||||
<BsmButton className="inline float-right rounded-md font-bold px-1 py-0.5 text-sm" text="Appliquer" typeColor="primary" withBar={false} onClick={handleApply}/>
|
||||
{haveChanged && <div className="glow-on-hover !opacity-100"></div>}
|
||||
<BsmButton className="inline float-right rounded-md font-bold px-1 py-0.5 text-sm" text="misc.apply" typeColor="primary" withBar={false} onClick={handleApply}/>
|
||||
<GlowEffect visible={haveChanged}/>
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { motion } from "framer-motion"
|
||||
import { forwardRef } from "react"
|
||||
import { useThemeColor } from "renderer/hooks/use-theme-color.hook"
|
||||
import { BsmIcon } from "../svgs/bsm-icon.component"
|
||||
|
||||
type Props = {
|
||||
className?: string,
|
||||
title?: string,
|
||||
linked?: boolean
|
||||
disabled?: boolean,
|
||||
onClick?: () => void
|
||||
}
|
||||
|
||||
export const LinkButton = motion(forwardRef((props: Props, ref) => {
|
||||
|
||||
const color = useThemeColor("first-color");
|
||||
|
||||
const linkedColor = (() => {
|
||||
if(props.disabled){ return "orange"; }
|
||||
if(props.linked){ return color; }
|
||||
return "red";
|
||||
})()
|
||||
|
||||
return (
|
||||
<div ref={ref} className={props.className} title={props.title} onClick={e => {e.preventDefault(); !props.disabled && props.onClick?.()}} style={{pointerEvents: props.disabled ? "none" : "auto"}}>
|
||||
<span className="absolute top-0 left-0 h-full w-full rounded-full brightness-50 opacity-75 dark:opacity-20 dark:filter-none" style={{backgroundColor: linkedColor}}/>
|
||||
<BsmIcon className="p-1 absolute top-0 left-0 h-full w-full !bg-transparent -rotate-45 brightness-150" icon={props.linked ? "link" : "unlink"} style={{color: linkedColor}} />
|
||||
</div>
|
||||
)
|
||||
}))
|
||||
+159
-86
@@ -3,102 +3,162 @@ import { BSVersion } from "shared/bs-version.interface"
|
||||
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react"
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface"
|
||||
import { Subscription } from "rxjs"
|
||||
import { MapItem, ParsedMapDiff } from "./map-item.component"
|
||||
import { BsvMapCharacteristic, MapFilter } from "shared/models/maps/beat-saver.model"
|
||||
import { MapFilter } from "shared/models/maps/beat-saver.model"
|
||||
import { useInView } from "framer-motion"
|
||||
import { MapsDownloaderService } from "renderer/services/maps-downloader.service"
|
||||
import { BsmImage } from "../shared/bsm-image.component"
|
||||
import BeatConflict from "../../../../assets/images/apngs/beat-conflict.png"
|
||||
import { BsmButton } from "../shared/bsm-button.component"
|
||||
import { VariableSizeList } from "react-window"
|
||||
import { MapsRow } from "./maps-row.component"
|
||||
import { BehaviorSubject } from "rxjs"
|
||||
import { debounceTime, last, map, mergeMap, throttleTime } from "rxjs/operators"
|
||||
import { BeatSaverService } from "renderer/services/thrird-partys/beat-saver.service"
|
||||
import { OsDiagnosticService } from "renderer/services/os-diagnostic.service"
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook"
|
||||
import BeatWaitingImg from "../../../../assets/images/apngs/beat-waiting.png"
|
||||
import BeatConflict from "../../../../assets/images/apngs/beat-conflict.png"
|
||||
import { BsmImage } from "../shared/bsm-image.component"
|
||||
import { BsmButton } from "../shared/bsm-button.component"
|
||||
import TextProgressBar from "../progress-bar/text-progress-bar.component"
|
||||
|
||||
type Props = {
|
||||
version: BSVersion,
|
||||
className?: string,
|
||||
filter?: MapFilter
|
||||
search?: string,
|
||||
linked?: boolean
|
||||
}
|
||||
|
||||
export const LocalMapsListPanel = forwardRef(({version, className, filter, search} : Props, forwardRef) => {
|
||||
export const LocalMapsListPanel = forwardRef(({version, className, filter, search, linked} : Props, forwardRef) => {
|
||||
|
||||
const mapsManager = MapsManagerService.getInstance();
|
||||
const mapsDownloader = MapsDownloaderService.getInstance();
|
||||
const bsaver = BeatSaverService.getInstance();
|
||||
const os = OsDiagnosticService.getInstance();
|
||||
|
||||
const ref = useRef(null)
|
||||
const isVisible = useInView(ref, {once: true});
|
||||
const [maps, setMaps] = useState<BsmLocalMap[]>([]);
|
||||
const [subs] = useState<Subscription[]>([]);
|
||||
const [selectedMaps, setSelectedMaps] = useState([]);
|
||||
const t = useTranslation();
|
||||
const ref = useRef(null)
|
||||
const isVisible = useInView(ref, {once: true, amount: .5});
|
||||
const [maps, setMaps] = useState<BsmLocalMap[]>(null);
|
||||
const [subs] = useState<Subscription[]>([]);
|
||||
const [selectedMaps$] = useState(new BehaviorSubject<BsmLocalMap[]>([]));
|
||||
const [itemPerRow, setItemPerRow] = useState(2);
|
||||
const [listHeight, setListHeight] = useState(0);
|
||||
|
||||
const [loadPercent$] = useState(new BehaviorSubject(0));
|
||||
|
||||
useImperativeHandle(forwardRef ,()=>({
|
||||
deleteMaps(){
|
||||
const mapsToDelete = selectedMaps.length === 0 ? maps : selectedMaps
|
||||
mapsManager.deleteMaps(mapsToDelete, version).finally(loadMaps);
|
||||
const mapsToDelete = selectedMaps$.value.length === 0 ? maps : selectedMaps$.value;
|
||||
mapsManager.deleteMaps(mapsToDelete, version).then(res => {
|
||||
if(!res){ return; }
|
||||
removeMapsFromList(mapsToDelete);
|
||||
selectedMaps$.next([]);
|
||||
});
|
||||
},
|
||||
exportMaps(){
|
||||
mapsManager.exportMaps(version, selectedMaps)
|
||||
mapsManager.exportMaps(version, selectedMaps$.value);
|
||||
},
|
||||
getMaps(){
|
||||
return maps;
|
||||
}
|
||||
}), [selectedMaps, maps, version]);
|
||||
}), [selectedMaps$.value, maps, version]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if(isVisible){
|
||||
loadMaps();
|
||||
subs.push(mapsManager.versionLinked$.subscribe(loadMaps));
|
||||
subs.push(mapsManager.versionUnlinked$.subscribe(loadMaps));
|
||||
mapsDownloader.addOnMapDownloadedListener(loadMaps);
|
||||
mapsDownloader.addOnMapDownloadedListener((map, targerVersion) => {
|
||||
if(targerVersion !== version){ return; }
|
||||
setMaps(maps => maps ? [map, ...maps] : [map]);
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
setMaps(() => []);
|
||||
setMaps(() => null);
|
||||
loadPercent$.next(0);
|
||||
subs.forEach(s => s.unsubscribe());
|
||||
mapsDownloader.removeOnMapDownloadedListene(loadMaps);
|
||||
mapsDownloader.removeOnMapDownloadedListener(loadMaps);
|
||||
}
|
||||
}, [isVisible, version]);
|
||||
}, [isVisible, version, linked]);
|
||||
|
||||
const loadMaps = () => {
|
||||
subs.push(mapsManager.getMaps(version).subscribe(localMaps => setMaps(() => [...localMaps])));
|
||||
}
|
||||
useEffect(() => {
|
||||
|
||||
if(!isVisible){ return () => {}; }
|
||||
|
||||
const handleDelete = useCallback((map: BsmLocalMap) => {
|
||||
mapsManager.deleteMaps([map], version).then(res => res && loadMaps())
|
||||
}, [version]);
|
||||
const updateItemPerRow = (listWidth: number) => {
|
||||
const newPerRow = Math.min(Math.floor(listWidth / 400), 3);
|
||||
if(newPerRow === itemPerRow){ return; }
|
||||
setItemPerRow(newPerRow);
|
||||
};
|
||||
|
||||
const extractMapDiffs = (map: BsmLocalMap): Map<BsvMapCharacteristic, ParsedMapDiff[]> => {
|
||||
const res = new Map<BsvMapCharacteristic, ParsedMapDiff[]>();
|
||||
if(map.bsaverInfo?.versions[0]?.diffs){
|
||||
map.bsaverInfo.versions[0].diffs.forEach(diff => {
|
||||
const arr = res.get(diff.characteristic) || [];
|
||||
const diffName = map.rawInfo._difficultyBeatmapSets.find(set => set._beatmapCharacteristicName === diff.characteristic)._difficultyBeatmaps.find(rawDiff => rawDiff._difficulty === diff.difficulty)?._customData?._difficultyLabel || diff.difficulty
|
||||
arr.push({name: diffName, type: diff.difficulty, stars: diff.stars});
|
||||
res.set(diff.characteristic, arr);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
const heightObserver$ = new BehaviorSubject(0);
|
||||
|
||||
map.rawInfo._difficultyBeatmapSets.forEach(set => {
|
||||
set._difficultyBeatmaps.forEach(diff => {
|
||||
const arr = res.get(set._beatmapCharacteristicName) || [];
|
||||
arr.push({name: diff._customData?._difficultyLabel || diff._difficulty, type: diff._difficulty, stars: null});
|
||||
res.set(set._beatmapCharacteristicName, arr);
|
||||
});
|
||||
const observer = new ResizeObserver(() => {
|
||||
updateItemPerRow(ref.current?.clientWidth || 0);
|
||||
heightObserver$.next(ref.current?.clientHeight || 0)
|
||||
});
|
||||
|
||||
return res;
|
||||
observer.observe(ref.current);
|
||||
|
||||
const sub = heightObserver$.pipe(debounceTime(100)).subscribe(setListHeight);
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
sub.unsubscribe();
|
||||
}
|
||||
|
||||
}, [isVisible, itemPerRow])
|
||||
|
||||
const loadMaps = () => {
|
||||
|
||||
setMaps(() => null);
|
||||
loadPercent$.next(0);
|
||||
|
||||
const loadMapsObs$ = mapsManager.getMaps(version);
|
||||
|
||||
loadMapsObs$.pipe(map(progess => {
|
||||
return Math.floor(((progess.loaded / progess.total) * 100));
|
||||
})).subscribe(percent => loadPercent$.next(percent));
|
||||
|
||||
subs.push(loadMapsObs$.pipe(
|
||||
last(),
|
||||
mergeMap(async progress => {
|
||||
if(os.isOffline){ return progress.maps; }
|
||||
const maps = progress.maps;
|
||||
const details = await bsaver.getMapDetailsFromHashs(maps.map(map => map.hash));
|
||||
return maps.map(map => {
|
||||
map.bsaverInfo = details.find(d => d.versions.at(0).hash === map.hash);
|
||||
return map;
|
||||
})
|
||||
})
|
||||
).subscribe({
|
||||
next: maps => setMaps(() => maps),
|
||||
complete: () => loadPercent$.next(0)
|
||||
}));
|
||||
}
|
||||
|
||||
const removeMapsFromList = (mapsToRemove: BsmLocalMap[]) => {
|
||||
const filtredMaps = maps.filter(map => !mapsToRemove.some(toDeleteMaps => map.hash === toDeleteMaps.hash));
|
||||
setMaps(() => filtredMaps);
|
||||
};
|
||||
|
||||
const handleDelete = useCallback((map: BsmLocalMap) => {
|
||||
mapsManager.deleteMaps([map], version).then(res => res && removeMapsFromList([map]));
|
||||
}, [version, maps]);
|
||||
|
||||
const onMapSelected = useCallback((map: BsmLocalMap) => {
|
||||
const maps = [...selectedMaps];
|
||||
if(maps.some(selectedMap => selectedMap.hash === map.hash)){
|
||||
const i = maps.findIndex(selectedMap => selectedMap.hash === map.hash);
|
||||
maps.splice(i, 1);
|
||||
|
||||
const mapsCopy = [...selectedMaps$.value];
|
||||
if(mapsCopy.some(selectedMap => selectedMap.hash === map.hash)){
|
||||
const i = mapsCopy.findIndex(selectedMap => selectedMap.hash === map.hash);
|
||||
mapsCopy.splice(i, 1);
|
||||
}
|
||||
else{
|
||||
maps.push(map);
|
||||
mapsCopy.push(map);
|
||||
}
|
||||
setSelectedMaps(() => maps);
|
||||
}, [selectedMaps]);
|
||||
|
||||
selectedMaps$.next(mapsCopy);
|
||||
|
||||
}, [selectedMaps$.value]);
|
||||
|
||||
const isMapFitFilter = (map: BsmLocalMap): boolean => {
|
||||
|
||||
@@ -215,46 +275,59 @@ export const LocalMapsListPanel = forwardRef(({version, className, filter, searc
|
||||
|
||||
}
|
||||
|
||||
const renderMaps = (): JSX.Element[] => {
|
||||
return maps.reduce((acc, current) => {
|
||||
if(isMapFitFilter(current)){
|
||||
acc.push(renderMapItem(current));
|
||||
|
||||
const preppedMaps: BsmLocalMap[][] = (() => {
|
||||
|
||||
if(!maps){ return []; }
|
||||
|
||||
const res: BsmLocalMap[][] = [];
|
||||
let mapsRow: BsmLocalMap[] = []
|
||||
|
||||
for(const map of maps){
|
||||
if(!isMapFitFilter(map)){ continue; }
|
||||
if(mapsRow.length === itemPerRow){
|
||||
res.push(mapsRow);
|
||||
mapsRow = [];
|
||||
}
|
||||
return acc
|
||||
}, []);
|
||||
mapsRow.push(map);
|
||||
}
|
||||
|
||||
if(mapsRow.length){
|
||||
res.push(mapsRow);
|
||||
}
|
||||
|
||||
return res;
|
||||
})();
|
||||
|
||||
if(!maps){
|
||||
return (
|
||||
<div ref={ref} className={className}>
|
||||
<div className="h-full flex flex-col items-center justify-center flex-wrap gap-1 text-gray-800 dark:text-gray-200">
|
||||
<BsmImage className="w-32 h-32 spin-loading" image={BeatWaitingImg}/>
|
||||
<span className="font-bold">{t("modals.download-maps.loading-maps")}</span>
|
||||
<TextProgressBar value$={loadPercent$}/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const renderMapItem = (map: BsmLocalMap) => {
|
||||
|
||||
return <MapItem
|
||||
key={map.hash}
|
||||
hash={map.hash}
|
||||
title={map.rawInfo._songName}
|
||||
coverUrl={map.coverUrl}
|
||||
songUrl={map.songUrl}
|
||||
autor={map.rawInfo._levelAuthorName}
|
||||
songAutor={map.rawInfo._songAuthorName}
|
||||
bpm={map.rawInfo._beatsPerMinute}
|
||||
duration={map.bsaverInfo?.metadata?.duration}
|
||||
selected={selectedMaps.some(_map => _map.hash === map.hash)}
|
||||
diffs={extractMapDiffs(map)} mapId={map.bsaverInfo?.id} ranked={map.bsaverInfo?.ranked} autorId={map.bsaverInfo?.uploader?.id} likes={map.bsaverInfo?.stats?.upvotes} createdAt={map.bsaverInfo?.createdAt}
|
||||
onDelete={handleDelete}
|
||||
onSelected={onMapSelected}
|
||||
callBackParam={map}
|
||||
/>;
|
||||
if(!maps.length){
|
||||
return (
|
||||
<div ref={ref} className={className}>
|
||||
<div className="h-full flex flex-col items-center justify-center flex-wrap gap-1 text-gray-800 dark:text-gray-200">
|
||||
<BsmImage className="h-32" image={BeatConflict}/>
|
||||
<span className="font-bold">{t("pages.version-viewer.maps.tabs.maps.empty-maps.text")}</span>
|
||||
<BsmButton className="font-bold rounded-md p-2" text="pages.version-viewer.maps.tabs.maps.empty-maps.button" typeColor="primary" withBar={false} onClick={e => {e.preventDefault(); mapsDownloader.openDownloadMapModal(version)}}/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div ref={ref} className={className}>
|
||||
<ul className="p-3 w-full grow flex flex-wrap justify-center content-start gap-2 overflow-y-scroll scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900">
|
||||
{maps?.length ? renderMaps() : (
|
||||
<div className="h-full flex flex-col items-center justify-center flex-wrap gap-1">
|
||||
<BsmImage className="h-32" image={BeatConflict}/>
|
||||
<span className="font-bold">{t("pages.version-viewer.maps.tabs.maps.empty-maps.text")}</span>
|
||||
<BsmButton className="font-bold rounded-md p-2" text="pages.version-viewer.maps.tabs.maps.empty-maps.button" typeColor="primary" withBar={false} onClick={e => {e.preventDefault(); mapsDownloader.openDownloadMapModal(version)}}/>
|
||||
</div>
|
||||
)}
|
||||
</ul>
|
||||
<VariableSizeList className="p-0 scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900" width={"100%"} height={listHeight} itemSize={() => 108} itemCount={preppedMaps.length} itemData={preppedMaps} layout="vertical" style={{scrollbarGutter: "stable both-edges"}} itemKey={(i, data) => data[i].map(map => map.hash).join()}>
|
||||
{(props) => <MapsRow maps={props.data[props.index]} style={props.style} selectedMaps$={selectedMaps$} onMapSelect={onMapSelected} onMapDelete={handleDelete}/>}
|
||||
</VariableSizeList>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { MAP_DIFFICULTIES } from "renderer/partials/maps/map-difficulties/map-difficulties";
|
||||
import { MAP_DIFFICULTIES_COLORS } from "renderer/partials/maps/map-difficulties/map-difficulties-colors"
|
||||
import useDoubleClick from "use-double-click";
|
||||
import { GlowEffect } from "../shared/glow-effect.component";
|
||||
|
||||
export type ParsedMapDiff = {type: BsvMapDifficultyType, name: string, stars: number}
|
||||
|
||||
@@ -92,7 +93,12 @@ export const MapItem = memo(({hash, title, autor, songAutor, coverUrl, songUrl,
|
||||
return diffLabel;
|
||||
}
|
||||
|
||||
const openPreview = () => linkOpener.open(previewUrl, true);
|
||||
const openPreview = () => {
|
||||
if(audioPlayer.playing){
|
||||
audioPlayer.pause();
|
||||
}
|
||||
linkOpener.open(previewUrl, true);
|
||||
}
|
||||
const copyBsr = () => navigator.clipboard.writeText(`!bsr ${mapId}`);
|
||||
const toogleMusic = () => {
|
||||
if(songPlaying){
|
||||
@@ -147,8 +153,8 @@ export const MapItem = memo(({hash, title, autor, songAutor, coverUrl, songUrl,
|
||||
}
|
||||
|
||||
return (
|
||||
<motion.li className="relative h-[100px] min-w-[370px] shrink-0 grow basis-0 text-white group cursor-pointer" onHoverStart={() => setHovered(true)} onHoverEnd={() => setHovered(false)} style={{zIndex: hovered && 5, transform: "translateZ(0) scale(1.0, 1.0)", backfaceVisibility: "hidden"}}>
|
||||
{(hovered || selected) && onSelected && <motion.span className="glow-on-hover !transition-none" animate={{opacity: 1}} transition={{duration: .2, ease: "linear"}}/>}
|
||||
<motion.li className="relative h-[100px] w-[400px] min-w-[370px] shrink-0 grow basis-0 text-white group cursor-pointer" onHoverStart={() => setHovered(true)} onHoverEnd={() => setHovered(false)} style={{zIndex: hovered && 5, transform: "translateZ(0) scale(1.0, 1.0)", backfaceVisibility: "hidden"}}>
|
||||
<GlowEffect visible={hovered || selected && !!onSelected}/>
|
||||
<AnimatePresence>
|
||||
{(diffsPanelHovered || bottomBarHovered) && (
|
||||
<motion.ul key={hash} className="absolute top-[calc(100%-10px)] w-full h-fit max-h-[200%] pt-4 pb-2 px-2 overflow-y-scroll bg-light-main-color-3 dark:bg-main-color-3 text-main-color-1 dark:text-current brightness-125 rounded-md flex flex-col gap-3 scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900 shadow-sm shadow-black" initial={{opacity: 0}} animate={{opacity: 1}} exit={{opacity: 0}} transition={{duration: .15}} onHoverStart={diffsPanelHoverStart} onHoverEnd={diffsPanelHoverEnd}>
|
||||
@@ -224,19 +230,15 @@ export const MapItem = memo(({hash, title, autor, songAutor, coverUrl, songUrl,
|
||||
<span className="absolute w-[10px] h-[10px] bottom-0 right-full bg-inherit" style={{clipPath: 'path("M11 11 L11 0 L10 0 A10 10 0 0 1 0 10 L 0 11 Z")'}}/>
|
||||
|
||||
<div className="flex flex-col justify-center items-center gap-1 w-full h-full overflow-hidden opacity-0 group-hover:opacity-100">
|
||||
{onDelete && !downloading && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-200" iconColor={color} icon="trash" withBar={false} onClick={e => {e.stopPropagation(); onDelete(callBackParam)}}/>}
|
||||
{onDownload && !downloading && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-200" iconColor={color} icon="download" withBar={false} onClick={e => {e.stopPropagation(); onDownload(callBackParam)}}/>}
|
||||
{onCancelDownload && !downloading && <BsmButton className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-200" iconColor="red" icon="cross" withBar={false} onClick={e => {e.stopPropagation(); onCancelDownload(callBackParam)}}/>}
|
||||
{downloading && <BsmBasicSpinner className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2 flex items-center justify-center" spinnerClassName="brightness-200" style={{color}} thikness="3px"/>}
|
||||
{previewUrl && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-200" iconColor={color} icon="eye" withBar={false} onClick={e => {e.stopPropagation(); openPreview()}}/>}
|
||||
{mapId && <BsmButton className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-200" iconColor={color} icon="twitch" withBar={false} onClick={e => {e.stopPropagation(); copyBsr()}}/>}
|
||||
{onDelete && !downloading && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-75 dark:brightness-200" iconColor={color} icon="trash" withBar={false} onClick={e => {e.stopPropagation(); onDelete(callBackParam)}}/>}
|
||||
{onDownload && !downloading && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-75 dark:brightness-200" iconColor={color} icon="download" withBar={false} onClick={e => {e.stopPropagation(); onDownload(callBackParam)}}/>}
|
||||
{onCancelDownload && !downloading && <BsmButton className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-75 dark:brightness-200" iconColor="red" icon="cross" withBar={false} onClick={e => {e.stopPropagation(); onCancelDownload(callBackParam)}}/>}
|
||||
{downloading && <BsmBasicSpinner className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2 flex items-center justify-center" spinnerClassName="brightness-75 dark:brightness-200" style={{color}} thikness="3px"/>}
|
||||
{previewUrl && <BsmButton className="w-6 h-6 p-[2px] rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-75 dark:brightness-200" iconColor={color} icon="eye" withBar={false} onClick={e => {e.stopPropagation(); openPreview()}}/>}
|
||||
{mapId && <BsmButton className="w-6 h-6 p-1 rounded-md !bg-inherit hover:!bg-light-main-color-2 hover:dark:!bg-main-color-2" iconClassName="w-full h-full brightness-75 dark:brightness-200" iconColor={color} icon="twitch" withBar={false} onClick={e => {e.stopPropagation(); copyBsr()}}/>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.li>
|
||||
)
|
||||
}, areEqual)
|
||||
|
||||
function areEqual(prevProps: MapItemProps, nextProps: MapItemProps): boolean {
|
||||
return equal(prevProps, nextProps);
|
||||
}
|
||||
}, equal);
|
||||
|
||||
+39
-12
@@ -15,6 +15,9 @@ import { OsDiagnosticService } from "renderer/services/os-diagnostic.service"
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook"
|
||||
import { BsmIcon } from "../svgs/bsm-icon.component"
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook"
|
||||
import { LinkButton } from "./link-button.component"
|
||||
import { debounceTime } from "rxjs/operators"
|
||||
import { FolderLinkerService } from "renderer/services/folder-linker.service"
|
||||
|
||||
type Props = {
|
||||
version?: BSVersion
|
||||
@@ -25,12 +28,14 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
const mapsService = MapsManagerService.getInstance();
|
||||
const mapsDownloader = MapsDownloaderService.getInstance();
|
||||
const osDiagnostic = OsDiagnosticService.getInstance();
|
||||
const linker = FolderLinkerService.getInstance();
|
||||
|
||||
const [tabIndex, setTabIndex] = useState(0);
|
||||
const [mapFilter, setMapFilter] = useState<MapFilter>({});
|
||||
const [mapSearch, setMapSearch] = useState("");
|
||||
const [playlistSearch, setPlaylistSearch] = useState("");
|
||||
const [mapsLinked, setMapsLinked] = useState(false);
|
||||
const [linkingPending, setLinkingPending] = useState(false);
|
||||
const isOnline = useObservable(osDiagnostic.isOnline$);
|
||||
const color = useThemeColor("first-color");
|
||||
const t = useTranslation();
|
||||
@@ -38,6 +43,23 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
loadMapIsLinked();
|
||||
|
||||
const sub = mapsService.$mapsLinkingPending(version).pipe(debounceTime(50)).subscribe(setLinkingPending);
|
||||
|
||||
const onMapsLinked = (folder: string) => {
|
||||
if(!folder.includes("CustomLevels")){ return; }
|
||||
loadMapIsLinked();
|
||||
}
|
||||
|
||||
linker.onFolderLinked(onMapsLinked);
|
||||
linker.onFolderUnlinked(onMapsLinked);
|
||||
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
linker.removeOnFolderLinked(onMapsLinked);
|
||||
linker.removeOnFolderUnlinked(onMapsLinked);
|
||||
}
|
||||
|
||||
}, [version]);
|
||||
|
||||
const loadMapIsLinked = () => {
|
||||
@@ -53,19 +75,17 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
|
||||
const handleMapsLinkClick = () => {
|
||||
if(!mapsLinked){
|
||||
return mapsService.linkVersion(version).then(loadMapIsLinked);
|
||||
return mapsService.linkVersion(version);
|
||||
}
|
||||
return mapsService.unlinkVersion(version).then(loadMapIsLinked);
|
||||
return mapsService.unlinkVersion(version);
|
||||
}
|
||||
|
||||
const handleMapsAddClick = () => {
|
||||
mapsDownloader.openDownloadMapModal(version);
|
||||
mapsDownloader.openDownloadMapModal(version, mapsRef.current.getMaps?.());
|
||||
}
|
||||
|
||||
const renderTab = (props: DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>, text: string, index: number): JSX.Element => {
|
||||
|
||||
const linkedColor = mapsLinked ? color : "red";
|
||||
|
||||
const onClickLink = (index: number) => {
|
||||
if(index === 0){ handleMapsLinkClick(); }
|
||||
}
|
||||
@@ -91,10 +111,17 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
</motion.div>
|
||||
)}
|
||||
{(!!version) && (
|
||||
<motion.div variants={variants} whileHover="hover" whileTap="tap" initial={{rotate: 0}} className="block p-0.5 h-[calc(100%-5px)] aspect-square blur-0 hover:brightness-75" title={t(mapsLinked ? "pages.version-viewer.maps.tabs.maps.actions.link-maps.tooltips.unlink" : "pages.version-viewer.maps.tabs.maps.actions.link-maps.tooltips.link")} onClick={e => {e.stopPropagation(); onClickLink(index)}}>
|
||||
<span className="absolute top-0 left-0 h-full w-full rounded-full brightness-50 opacity-75 dark:opacity-20 dark:filter-none" style={{backgroundColor: linkedColor}}/>
|
||||
<BsmIcon className="p-1 absolute top-0 left-0 h-full w-full !bg-transparent -rotate-45 brightness-150" icon={mapsLinked ? "link" : "unlink"} style={{color: linkedColor}} />
|
||||
</motion.div>
|
||||
<LinkButton
|
||||
variants={variants}
|
||||
disabled={linkingPending}
|
||||
whileHover="hover"
|
||||
whileTap="tap"
|
||||
initial={{rotate: 0}}
|
||||
className="block p-0.5 h-[calc(100%-5px)] aspect-square blur-0 hover:brightness-75"
|
||||
linked={mapsLinked}
|
||||
title={t(mapsLinked ? "pages.version-viewer.maps.tabs.maps.actions.link-maps.tooltips.unlink" : "pages.version-viewer.maps.tabs.maps.actions.link-maps.tooltips.link")}
|
||||
onClick={() => onClickLink(index)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -120,7 +147,7 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
<div className="w-full h-full flex flex-col items-center justify-center">
|
||||
<nav className="w-full shrink-0 flex h-9 justify-center px-40 gap-2 mb-3 text-main-color-1 dark:text-white">
|
||||
<div className="h-full rounded-full bg-light-main-color-2 dark:bg-main-color-2 grow p-[6px]">
|
||||
<input type="text" className="h-full w-full bg-light-main-color-1 dark:bg-main-color-1 rounded-full px-2" placeholder={t("pages.version-viewer.maps.search-bar.search-placeholder")} value={tabIndex === 0 ? mapSearch : playlistSearch} onChange={e => handleSearch(e.target.value)}/>
|
||||
<input type="text" className="h-full w-full bg-light-main-color-1 dark:bg-main-color-1 rounded-full px-2" placeholder={t("pages.version-viewer.maps.search-bar.search-placeholder")} value={tabIndex === 0 ? mapSearch : playlistSearch} onChange={e => handleSearch(e.target.value)} tabIndex={-1}/>
|
||||
</div>
|
||||
<BsmDropdownButton className="h-full relative z-[1] flex justify-center" buttonClassName="flex items-center justify-center h-full rounded-full px-2 py-1" icon="filter" text="pages.version-viewer.maps.search-bar.filters-btn" withBar={false}>
|
||||
<FilterPanel className="absolute top-[calc(100%+3px)] origin-top w-[500px] h-fit p-2 rounded-md shadow-md shadow-black" filter={mapFilter} onChange={setMapFilter}/>
|
||||
@@ -130,8 +157,8 @@ export function MapsPlaylistsPanel({version}: Props) {
|
||||
<div className="w-full h-full flex flex-col bg-light-main-color-3 dark:bg-main-color-2 rounded-md shadow-black shadow-md overflow-hidden">
|
||||
<TabNavBar className="!rounded-none shadow-sm" tabIndex={tabIndex} tabsText={["misc.maps", "misc.playlists"]} onTabChange={setTabIndex} renderTab={renderTab}/>
|
||||
<div className="w-full grow min-h-0 flex flex-row items-center transition-transform duration-300" style={{transform: `translate(${-(tabIndex * 100)}%, 0)`}}>
|
||||
<LocalMapsListPanel ref={mapsRef} className="w-full h-full shrink-0 flex flex-col" version={version} filter={mapFilter} search={mapSearch}/>
|
||||
<div className="w-full h-full shrink-0 flex flex-col justify-center items-center content-center gap-2 overflow-hidden">
|
||||
<LocalMapsListPanel ref={mapsRef} className="w-full h-full shrink-0 flex flex-col" version={version} filter={mapFilter} search={mapSearch} linked={mapsLinked}/>
|
||||
<div className="w-full h-full shrink-0 flex flex-col justify-center items-center content-center gap-2 overflow-hidden text-gray-800 dark:text-gray-200">
|
||||
<BsmImage className="rounded-md" image={wipGif}/>
|
||||
<span>Coming soon</span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { CSSProperties, memo } from "react"
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook"
|
||||
import { distinctUntilChanged, map } from "rxjs/operators"
|
||||
import { BehaviorSubject } from "rxjs"
|
||||
import { BsvMapCharacteristic } from "shared/models/maps/beat-saver.model"
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface"
|
||||
import { ParsedMapDiff, MapItem } from "./map-item.component"
|
||||
import equal from "fast-deep-equal/es6"
|
||||
|
||||
type Props = {
|
||||
maps: BsmLocalMap[],
|
||||
style?: CSSProperties,
|
||||
onMapDelete: (map: BsmLocalMap) => void,
|
||||
onMapSelect: (map: BsmLocalMap) => void,
|
||||
selectedMaps$: BehaviorSubject<BsmLocalMap[]>
|
||||
}
|
||||
|
||||
export const MapsRow = memo(({maps, style, selectedMaps$, onMapSelect, onMapDelete}: Props) => {
|
||||
|
||||
const selectedMaps = useObservable<BsmLocalMap[]>(selectedMaps$.pipe(
|
||||
map(selectedMaps => selectedMaps.filter(selected => maps.some(map => map.hash === selected.hash))),
|
||||
distinctUntilChanged(equal)
|
||||
), []);
|
||||
|
||||
const extractMapDiffs = (map: BsmLocalMap): Map<BsvMapCharacteristic, ParsedMapDiff[]> => {
|
||||
const res = new Map<BsvMapCharacteristic, ParsedMapDiff[]>();
|
||||
if(map.bsaverInfo?.versions[0]?.diffs){
|
||||
map.bsaverInfo.versions[0].diffs.forEach(diff => {
|
||||
const arr = res.get(diff.characteristic) || [];
|
||||
const diffName = map.rawInfo._difficultyBeatmapSets.find(set => set._beatmapCharacteristicName === diff.characteristic)._difficultyBeatmaps.find(rawDiff => rawDiff._difficulty === diff.difficulty)?._customData?._difficultyLabel || diff.difficulty
|
||||
arr.push({name: diffName, type: diff.difficulty, stars: diff.stars});
|
||||
res.set(diff.characteristic, arr);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
map.rawInfo._difficultyBeatmapSets.forEach(set => {
|
||||
set._difficultyBeatmaps.forEach(diff => {
|
||||
const arr = res.get(set._beatmapCharacteristicName) || [];
|
||||
arr.push({name: diff._customData?._difficultyLabel || diff._difficulty, type: diff._difficulty, stars: null});
|
||||
res.set(set._beatmapCharacteristicName, arr);
|
||||
});
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
const renderMapItem = (map: BsmLocalMap) => {
|
||||
|
||||
return <MapItem
|
||||
key={map.hash}
|
||||
hash={map.hash}
|
||||
title={map.rawInfo._songName}
|
||||
coverUrl={map.coverUrl}
|
||||
songUrl={map.songUrl}
|
||||
autor={map.rawInfo._levelAuthorName}
|
||||
songAutor={map.rawInfo._songAuthorName}
|
||||
bpm={map.rawInfo._beatsPerMinute}
|
||||
duration={map.bsaverInfo?.metadata?.duration}
|
||||
selected={selectedMaps.some(selected => selected.hash === map.hash)}
|
||||
diffs={extractMapDiffs(map)} mapId={map.bsaverInfo?.id} ranked={map.bsaverInfo?.ranked} autorId={map.bsaverInfo?.uploader?.id} likes={map.bsaverInfo?.stats?.upvotes} createdAt={map.bsaverInfo?.createdAt}
|
||||
onDelete={onMapDelete}
|
||||
onSelected={onMapSelect}
|
||||
callBackParam={map}
|
||||
/>;
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="h-fit w-full flex flex-nowrap basis-0 gap-x-[8px] py-1 px-3" style={style}>
|
||||
{maps && maps.map(renderMapItem)}
|
||||
</ul>
|
||||
)
|
||||
}, equal);
|
||||
@@ -14,16 +14,19 @@ import { ModalComponent } from "renderer/services/modale.service";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BsvMapCharacteristic, BsvMapDetail, MapFilter, SearchOrder, SearchParams } from "shared/models/maps/beat-saver.model";
|
||||
import BeatWaitingImg from "../../../../../assets/images/apngs/beat-waiting.png";
|
||||
import BeatConflictImg from "../../../../../assets/images/apngs/beat-conflict.png";
|
||||
import equal from "fast-deep-equal/es6";
|
||||
import { ProgressBarService } from "renderer/services/progress-bar.service";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { OsDiagnosticService } from "renderer/services/os-diagnostic.service";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
|
||||
export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
export const DownloadMapsModal: ModalComponent<void, {version: BSVersion, ownedMaps: BsmLocalMap[]}> = ({resolver, data: { ownedMaps, version }}) => {
|
||||
|
||||
const beatSaver = BeatSaverService.getInstance();
|
||||
const mapsManager = MapsManagerService.getInstance();
|
||||
const mapsDownloader = MapsDownloaderService.getInstance();
|
||||
const progressBar = ProgressBarService.getInstance();
|
||||
const os = OsDiagnosticService.getInstance();
|
||||
|
||||
const currentDownload = useObservable(mapsDownloader.currentMapDownload$);
|
||||
const mapsInQueue = useObservable(mapsDownloader.mapsInQueue$);
|
||||
@@ -33,7 +36,9 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
const [query, setQuery] = useState("");
|
||||
const [maps, setMaps] = useState<BsvMapDetail[]>([]);
|
||||
const [sortOrder, setSortOrder] = useState<SearchOrder>(BSV_SORT_ORDER.at(0));
|
||||
const [ownedMapHashs, setOwnedMapHashs] = useState<string[]>([]);
|
||||
const [ownedMapHashs, setOwnedMapHashs] = useState<string[]>(ownedMaps?.map(map => map.hash) ?? []);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const isOnline = useObservable(os.isOnline$);
|
||||
const [searchParams, setSearchParams] = useState<SearchParams>({
|
||||
sortOrder,
|
||||
filter,
|
||||
@@ -53,13 +58,12 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
mapsManager.getMaps(data, false).toPromise().then(maps => setOwnedMapHashs(maps.map(map => map.hash)));
|
||||
|
||||
const onMapDownloaded = (map: BsvMapDetail, verion: BSVersion) => {
|
||||
if(!equal(verion, data) || !map?.versions){ return; }
|
||||
const downloadedHash = map.versions.at(0).hash;
|
||||
const onMapDownloaded = (map: BsmLocalMap, targerVersion: BSVersion) => {
|
||||
if(!equal(targerVersion, version)){ return; }
|
||||
const downloadedHash = map.hash;
|
||||
setOwnedMapHashs((prev) => [...prev, downloadedHash]);
|
||||
}
|
||||
|
||||
mapsDownloader.addOnMapDownloadedListener(onMapDownloaded);
|
||||
|
||||
if(mapsDownloader.isDownloading){
|
||||
@@ -67,13 +71,14 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
}
|
||||
|
||||
return () => {
|
||||
mapsDownloader.removeOnMapDownloadedListene(onMapDownloaded);
|
||||
mapsDownloader.removeOnMapDownloadedListener(onMapDownloaded);
|
||||
progressBar.setStyle(null);
|
||||
}
|
||||
}, [])
|
||||
|
||||
const loadMaps = (params: SearchParams) => {
|
||||
beatSaver.searchMaps(params).then((maps => setMaps(prev => [...prev, ...maps])));
|
||||
setLoading(() => true);
|
||||
beatSaver.searchMaps(params).then((maps => setMaps(prev => [...prev, ...maps]))).finally(() => setLoading(() => false));
|
||||
}
|
||||
|
||||
const extractMapDiffs = (map: BsvMapDetail): Map<BsvMapCharacteristic, ParsedMapDiff[]> => {
|
||||
@@ -93,7 +98,7 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
|
||||
const isMapOwned = map.versions.some(version => ownedMapHashs.includes(version.hash));
|
||||
const isDownloading = map.id === currentDownload?.map?.id;
|
||||
const inQueue = mapsInQueue.some(toDownload => equal(toDownload.version, data) && toDownload.map.id === map.id);
|
||||
const inQueue = mapsInQueue.some(toDownload => equal(toDownload.version, version) && toDownload.map.id === map.id);
|
||||
|
||||
return (
|
||||
<MapItem
|
||||
@@ -123,11 +128,11 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
}
|
||||
|
||||
const handleDownloadMap = useCallback((map: BsvMapDetail) => {
|
||||
mapsDownloader.addMapToDownload({map, version: data})
|
||||
mapsDownloader.addMapToDownload({map, version})
|
||||
}, []);
|
||||
|
||||
const handleCancelDownload = useCallback((map: BsvMapDetail) => {
|
||||
mapsDownloader.removeMapToDownload({map, version: data});
|
||||
mapsDownloader.removeMapToDownload({map, version});
|
||||
}, []);
|
||||
|
||||
const handleSortChange = (newSort: string) => {
|
||||
@@ -164,11 +169,11 @@ export const DownloadMapsModal: ModalComponent<void, BSVersion> = ({data}) => {
|
||||
<BsmButton className="shrink-0 rounded-full py-1 px-3 !bg-light-main-color-1 dark:!bg-main-color-1 flex justify-center items-center capitalize" icon="search" text="modals.download-maps.search-btn" withBar={false} onClick={e => {e.preventDefault(); handleSearch()}}/>
|
||||
<BsmSelect className="bg-light-main-color-1 dark:bg-main-color-1 rounded-full px-1 pb-0.5 text-center" options={sortOptions} onChange={handleSortChange}/>
|
||||
</div>
|
||||
<ul className="w-full grow flex content-start flex-wrap gap-2 px-2 overflow-y-scroll overflow-x-hidden scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900 z-0" >
|
||||
<ul className="w-full grow flex content-start flex-wrap gap-2 pt-1.5 px-2 overflow-y-scroll overflow-x-hidden scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900 z-0" >
|
||||
{maps.length === 0 ? (
|
||||
<div className="w-full h-full flex flex-col items-center justify-center">
|
||||
<img className="w-32 h-32 spin-loading" src={BeatWaitingImg} alt=" "/>
|
||||
<span className="text-lg">{t("modals.download-maps.loading-maps")}</span>
|
||||
<img className={`w-32 h-32 ${loading && "spin-loading"}`} src={loading ? BeatWaitingImg : BeatConflictImg} alt=" "/>
|
||||
<span className="text-lg">{t(loading ? "modals.download-maps.loading-maps" : isOnline ? "modals.download-maps.no-maps-found" : "modals.download-maps.no-internet")}</span>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { BsmButton } from 'renderer/components/shared/bsm-button.component'
|
||||
import { BsmImage } from 'renderer/components/shared/bsm-image.component'
|
||||
import { useTranslation } from 'renderer/hooks/use-translation.hook'
|
||||
import { ModalComponent, ModalExitCode } from 'renderer/services/modale.service'
|
||||
import BeatImpatient from "../../../../../assets/images/apngs/beat-impatient.png"
|
||||
|
||||
export const ImportVersionModal: ModalComponent<void> = ({resolver}) => {
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
return (
|
||||
<form>
|
||||
<h1 className="text-3xl uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200">{t("modals.bs-import-version.title")}</h1>
|
||||
<BsmImage className="mx-auto h-20" image={BeatImpatient}/>
|
||||
<p className="max-w-sm text-gray-800 dark:text-gray-200">{t("modals.bs-import-version.description")}</p>
|
||||
<div className="grid grid-flow-col grid-cols-2 gap-4 mt-4">
|
||||
<BsmButton typeColor="cancel" className="rounded-md text-center transition-all" onClick={() => resolver({exitCode: ModalExitCode.CANCELED})} withBar={false} text="misc.cancel"/>
|
||||
<BsmButton typeColor="primary" className="rounded-md text-center transition-all" onClick={() => resolver({exitCode: ModalExitCode.COMPLETED})} withBar={false} text="modals.bs-import-version.buttons.submit"/>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -2,14 +2,17 @@ import { useState } from "react";
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { BsmImage } from "renderer/components/shared/bsm-image.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { ModalComponent, ModalExitCode } from "renderer/services/modale.service";
|
||||
import { ModalComponent, ModalExitCode, ModalService } from "renderer/services/modale.service";
|
||||
import BeatImpatient from '../../../../../assets/images/apngs/beat-impatient.png'
|
||||
import { WhyCredentialsModal } from "./why-credentials-modal.component";
|
||||
|
||||
export const LoginModal: ModalComponent<{username: string, password: string, stay: boolean}> = ({resolver}) => {
|
||||
|
||||
const modal = ModalService.getInsance();
|
||||
|
||||
const [username, setUsername] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [stay, setStay] = useState(true);
|
||||
const [stay, setStay] = useState(false);
|
||||
const t = useTranslation();
|
||||
|
||||
const loggin = () => {
|
||||
@@ -17,10 +20,15 @@ export const LoginModal: ModalComponent<{username: string, password: string, sta
|
||||
resolver({exitCode: ModalExitCode.COMPLETED, data:{username, password, stay}});
|
||||
}
|
||||
|
||||
const whyCredentials = () => {
|
||||
modal.openModal(WhyCredentialsModal);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={(e) => {e.preventDefault(); loggin();}}>
|
||||
<h1 className="text-3xl uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200">{t("modals.steam-login.title")}</h1>
|
||||
<BsmImage className="mx-auto h-20" image={BeatImpatient} />
|
||||
|
||||
<div className="mb-2">
|
||||
<label className="block font-bold cursor-pointer tracking-wide text-gray-800 dark:text-gray-200" htmlFor="username">{t("modals.steam-login.inputs.username.label")}</label>
|
||||
<input className="w-full bg-light-main-color-1 dark:bg-main-color-1 px-1 py-[2px] rounded-md outline-none" onChange={e => setUsername(e.target.value)} value={username} type="text" name="username" id="username" placeholder={t("modals.steam-login.inputs.username.placeholder")}/>
|
||||
@@ -29,10 +37,9 @@ export const LoginModal: ModalComponent<{username: string, password: string, sta
|
||||
<label className="block font-bold cursor-pointer tracking-wide text-gray-800 dark:text-gray-200" htmlFor="password">{t("modals.steam-login.inputs.password.label")}</label>
|
||||
<input className="w-full bg-light-main-color-1 dark:bg-main-color-1 px-1 py-[2px] rounded-md outline-none" onChange={e => setPassword(e.target.value)} value={password} type="password" name="password" id="password" placeholder={t("modals.steam-login.inputs.password.placeholder")}/>
|
||||
</div>
|
||||
<div className="flex items-center content-center justify-start mb-3">
|
||||
<input onChange={e => setStay(e.target.checked)} checked={stay} className="mr-1" type="checkbox" name="stay" id="stay" />
|
||||
<label className="cursor-pointer text-gray-800 dark:text-gray-200" htmlFor="stay">{t("modals.steam-login.inputs.stay.label")}</label>
|
||||
</div>
|
||||
|
||||
<span onClick={whyCredentials} className="underline my-4 block cursor-pointer">{t("modals.steam-login.why-credentials")}</span>
|
||||
|
||||
<div className="grid grid-flow-col grid-cols-2 gap-4">
|
||||
<BsmButton typeColor="cancel" className="rounded-md text-center transition-all" onClick={() => {resolver({exitCode: ModalExitCode.CANCELED})}} withBar={false} text="misc.cancel"/>
|
||||
<BsmButton typeColor="primary" className="rounded-md text-center transition-all" type="submit" withBar={false} text="modals.steam-login.buttons.submit"/>
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
import Tippy from "@tippyjs/react";
|
||||
import { Variants } from "framer-motion";
|
||||
import { useEffect, useState } from "react";
|
||||
import { LinkButton } from "renderer/components/maps-mangement-components/link-button.component";
|
||||
import { BsmBasicSpinner } from "renderer/components/shared/bsm-basic-spinner/bsm-basic-spinner.component";
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { BsmIcon } from "renderer/components/svgs/bsm-icon.component";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { useThemeColor } from "renderer/hooks/use-theme-color.hook";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { ConfigurationService } from "renderer/services/configuration.service";
|
||||
import { FolderLinkerService } from "renderer/services/folder-linker.service";
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { ModalComponent } from "renderer/services/modale.service";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
|
||||
export const ShareFoldersModal: ModalComponent<void, BSVersion> = ({ data }) => {
|
||||
|
||||
const SHARED_FOLDERS_KEY = "default-shared-folders";
|
||||
|
||||
const config = ConfigurationService.getInstance();
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
const [folders, setFolders] = useState<string[]>([]);
|
||||
const versionPath = useObservable(ipc.sendV2<string>("get-version-full-path", {args: data}));
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const defaultFolders = config.get<string[]>(SHARED_FOLDERS_KEY);
|
||||
|
||||
const promises = Promise.allSettled(defaultFolders.map(async (folder) => {
|
||||
return ipc.sendV2<string>("relative-version-path-to-full", {args: {version: data, relative: folder}}).toPromise();
|
||||
}));
|
||||
|
||||
promises.then((res) => {
|
||||
|
||||
const fullPathFolders = res.reduce((acc, curent) => {
|
||||
if(curent.status !== "fulfilled"){ return acc; }
|
||||
acc.push(curent.value);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
setFolders(prev => Array.from(new Set([...prev, ...fullPathFolders]).values()));
|
||||
});
|
||||
|
||||
ipc.sendV2<string[]>("get-linked-folders", {args: data}).toPromise().then(linkedFolders => {
|
||||
setFolders(prev => Array.from(new Set([...prev, ...linkedFolders]).values()));
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if(!folders?.length){
|
||||
config.delete(SHARED_FOLDERS_KEY);
|
||||
return;
|
||||
}
|
||||
|
||||
const promises = Promise.allSettled(folders.map(async folder => {
|
||||
return ipc.sendV2<string>("full-version-path-to-relative", {args: {version: data, fullPath: folder}}).toPromise();
|
||||
}));
|
||||
|
||||
promises.then((res) => {
|
||||
const sharedFolders = res.reduce((acc, curent) => {
|
||||
if(curent.status !== "fulfilled"){ return acc; }
|
||||
acc.push(curent.value);
|
||||
return acc;
|
||||
}, [] as string[]);
|
||||
config.set(SHARED_FOLDERS_KEY, sharedFolders);
|
||||
});
|
||||
|
||||
}, [folders]);
|
||||
|
||||
const addFolder = async () => {
|
||||
const folder = await ipc.sendV2<{canceled: boolean, filePaths: string[]}, string>("choose-folder", {args: versionPath}).toPromise();
|
||||
|
||||
if(!folder || folder.canceled || !folder.filePaths?.length){ return; }
|
||||
const linkedFolder = folder.filePaths[0];
|
||||
|
||||
if(folders.includes(linkedFolder)){ return; }
|
||||
|
||||
setFolders(pre => [...pre, linkedFolder]);
|
||||
}
|
||||
|
||||
const removeFolder = (index: number) => {
|
||||
setFolders((prev) => prev.filter((_, i) => i !== index));
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="w-full max-w-md ">
|
||||
<h1 className="text-3xl uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200">{t("modals.shared-folders.title")}</h1>
|
||||
<p className="my-3">{t("modals.shared-folders.description")}</p>
|
||||
<ul className="flex flex-col gap-1 mb-2 h-[300px] max-h-[300px] overflow-scroll scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900 px-1">
|
||||
{folders.map((folder, index) => (
|
||||
<FolderItem key={index} path={folder} onDelete={() => {removeFolder(index)}}/>
|
||||
))}
|
||||
</ul>
|
||||
<div className="w-full h-12 rounded-md flex justify-center items-center cursor-pointer bg-light-main-color-1 dark:bg-main-color-1 hover:bg-light-main-color-3 hover:dark:bg-main-color-3" onClick={addFolder}>
|
||||
<BsmIcon className="aspect-square h-8" icon="add"/>
|
||||
<span className="font-bold">{t("modals.shared-folders.buttons.add-folder")}</span>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
type FolderProps = {
|
||||
path: string;
|
||||
onDelete?: () => void;
|
||||
}
|
||||
|
||||
const FolderItem = ({path, onDelete}: FolderProps) => {
|
||||
|
||||
const linker = FolderLinkerService.getInstance();
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
const name = path.split("\\").at(-1);
|
||||
const color = useThemeColor("first-color");
|
||||
|
||||
const variants: Variants = {
|
||||
hover: {rotate: 22.5},
|
||||
tap: {rotate: 45}
|
||||
};
|
||||
|
||||
const pending = useObservable(linker.isPending(path));
|
||||
const processing = useObservable(linker.isProcessing(path));
|
||||
const linkDisabled = pending || processing;
|
||||
|
||||
const [linked, setLinked] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
loadFolderIsLinked();
|
||||
}, [path]);
|
||||
|
||||
const loadFolderIsLinked = () => {
|
||||
linker.isFolderLinked(path).toPromise().then(setLinked);
|
||||
}
|
||||
|
||||
const onClickLink = () => {
|
||||
if(linked){
|
||||
return linker.unlinkFolder(path).toPromise().then(loadFolderIsLinked);
|
||||
}
|
||||
return linker.linkFolder(path).toPromise().then(loadFolderIsLinked);
|
||||
}
|
||||
|
||||
const cancelLink = () => {
|
||||
linker.cancelFolder(path);
|
||||
loadFolderIsLinked();
|
||||
}
|
||||
|
||||
return (
|
||||
<li className="w-full h-12 rounded-md shrink-0 flex flex-row items-center justify-between px-2 font-bold bg-light-main-color-1 dark:bg-main-color-1">
|
||||
<span className="cursor-help" title={path}>{name}</span>
|
||||
<div className="flex flex-row gap-1.5">
|
||||
<Tippy placement="left" content={t(`modals.shared-folders.buttons.${linked ? "unlink-folder" : "link-folder"}`)} arrow={false}>
|
||||
<LinkButton variants={variants} linked={linked} disabled={linkDisabled} whileHover="hover" whileTap="tap" className="p-0.5 h-7 shrink-0 aspect-square blur-0 cursor-pointer hover:brightness-75" onClick={onClickLink}/>
|
||||
</Tippy>
|
||||
{!processing ? (
|
||||
!pending ? (
|
||||
<BsmButton className="aspect-square h-7 rounded-md p-1" icon={"trash"} withBar={false} onClick={e => {e.preventDefault(); onDelete?.()}}/>
|
||||
) : (
|
||||
<BsmButton className="aspect-square h-7 rounded-md p-1" icon={"cross"} withBar={false} onClick={e => {e.preventDefault(); cancelLink()}}/>
|
||||
)
|
||||
) : (
|
||||
<BsmBasicSpinner className="aspect-square h-7 rounded-md p-1 dark:bg-main-color-2" thikness="3.5px" style={{color}}/>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { LinkOpenerService } from "renderer/services/link-opener.service";
|
||||
import { ModalComponent, ModalExitCode } from "renderer/services/modale.service"
|
||||
|
||||
export const WhyCredentialsModal: ModalComponent<void> = ({resolver}) => {
|
||||
|
||||
const t = useTranslation();
|
||||
const linkOpener = LinkOpenerService.getInstance();
|
||||
|
||||
const openTutorial = () => {
|
||||
linkOpener.open("https://steamcommunity.com/sharedfiles/filedetails/?id=1805934840");
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="w-min">
|
||||
<h1 className="text-3xl mb-2 uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200">{t("modals.steam-credentials.title")}</h1>
|
||||
|
||||
<p>{t("modals.steam-credentials.p-1")}</p>
|
||||
<a onClick={e => {e.preventDefault; openTutorial()}} className="underline text-blue-600 hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-600 mb-2 block cursor-pointer">
|
||||
https://steamcommunity.com/sharedfiles/filedetails/?id=1805934840
|
||||
</a>
|
||||
<p>{t("modals.steam-credentials.p-2")}</p>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export function Modal() {
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{ModalComponent && (
|
||||
{ModalComponent && resolver && (
|
||||
<div className="top-0 absolute w-screen h-screen flex content-center items-center justify-center z-[90]">
|
||||
<motion.span key="modal-overlay" onClick={() => modalSevice.resolve({exitCode: ModalExitCode.NO_CHOICE})} className="absolute top-0 bottom-0 right-0 left-0 bg-black" initial={{opacity: 0}} animate={{opacity: ModalComponent && .60}} exit={{opacity: 0}} transition={{duration: .2}}/>
|
||||
<motion.div key="modal" initial={{y: "100vh"}} animate={{y: 0}} exit={{y: "100vh"}}>
|
||||
|
||||
@@ -4,6 +4,8 @@ import { motion, Variants } from "framer-motion";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { AudioPlayerService } from "renderer/services/audio-player.service";
|
||||
|
||||
// Thanks to cheddZy for the icon : https://github.com/cheddZy
|
||||
|
||||
export const BsManagerIcon = memo(({className}: {className?: string}) => {
|
||||
|
||||
const audioPlayer = AudioPlayerService.getInstance();
|
||||
@@ -34,7 +36,7 @@ export const BsManagerIcon = memo(({className}: {className?: string}) => {
|
||||
<path d="M626.75,485.91l20.82,351.94a35.21,35.21,0,0,1-15.49,31.36L487.37,965.35l-.06,0A35.56,35.56,0,0,1,476,970.12a34.85,34.85,0,0,1-23.51-2.87L136.58,809.9a115.45,115.45,0,0,1-63.75-96.49L52,361.46a35.26,35.26,0,0,1,15.23-31.21l145.05-96.36a35.72,35.72,0,0,1,11.27-4.7,34.87,34.87,0,0,1,23.51,2.87L563,389.42a115.41,115.41,0,0,1,63.75,96.49Z"/>
|
||||
<path filter="brightness(30%)" d="M613.78,486.67l20.82,352a22.34,22.34,0,0,1-32.26,21.31L286.4,702.57A102.43,102.43,0,0,1,229.83,617L209,265a22.35,22.35,0,0,1,32.26-21.32L557.2,401.05A102.42,102.42,0,0,1,613.78,486.67Z"/>
|
||||
</g>
|
||||
<g fill="#fff">
|
||||
<g className="text-white stroke-black stroke-[2px] dark:stroke-0" fill="currentColor">
|
||||
<path d="M718.29,776.48,700,804.18c-40.63,39.5-87.06,67.25-133.81,90.75-87.32,43.9-203.67,77.19-249,90.34a48,48,0,0,1-26.17.16c-64-17.72-188.62-72-236.28-125.49a4.23,4.23,0,0,1,5.3-6.45c35.64,20.87,111.22,57.64,156.37,74.22,49.18,18.06,81.29,8.74,92.28-3.26a4.77,4.77,0,0,1,7.24.21c19.51,24,107.26,4.6,166.64-13C546.91,892.66,668.42,835.1,718.29,776.48Z"/>
|
||||
<path d="M522.09,933.81,374.64,989.49a3.92,3.92,0,0,0,1.44,7.58l54.62-.77a35.63,35.63,0,0,0,19-5.79l76-49.55A4,4,0,0,0,522.09,933.81Z"/>
|
||||
<path d="M218.92,195.56c-21.14.07-33.55,35.86-33.16,89.08.2,28,2.58,92.74,4.79,147.73.23,5.71-8.18,6.48-9,.81L143.13,162.47a4.38,4.38,0,0,1,7.12-4,63.63,63.63,0,0,0,21.93,11.85,4.61,4.61,0,0,0,5.9-3.72c4.2-27.7,16.63-58.74,37.35-88.74a4.36,4.36,0,0,1,7.56.69c10.86,23.87,49,103.8,93.34,152.79a4.65,4.65,0,0,1-5.62,7.22C274.14,219.18,227.7,195.54,218.92,195.56Z"/>
|
||||
|
||||
@@ -41,11 +41,12 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
)
|
||||
}
|
||||
|
||||
const cancel = () => {
|
||||
const versionDownload = downloaderService.currentBsVersionDownload$.value;
|
||||
downloaderService.cancelDownload().then(async res => {
|
||||
if(!res.success){ return; }
|
||||
if(!downloaderService.isVerification){
|
||||
const cancel = () => {
|
||||
const versionDownload = downloaderService.currentBsVersionDownload$.value;
|
||||
const wasVerification = downloaderService.isVerification;
|
||||
downloaderService.cancelDownload().then(async res => {
|
||||
if(!res.success){ return; }
|
||||
if(!wasVerification){
|
||||
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
|
||||
}
|
||||
});
|
||||
@@ -81,11 +82,9 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
const renderVersionText = () => {
|
||||
if(props.version.name){
|
||||
return (
|
||||
<Tippy content={props.version.BSVersion} placement="right-end" arrow={false} className="font-bold !bg-main-color-3" duration={[200, 0]}>
|
||||
<div className="h-8 flex items-center dark:text-gray-200 text-gray-800 overflow-hidden">
|
||||
<div ref={ref} className='whitespace-nowrap font-bold tracking-wide w-full text-center' style={{fontSize}}>{props.version.name}</div>
|
||||
</div>
|
||||
</Tippy>
|
||||
<div className="h-8 flex items-center dark:text-gray-200 text-gray-800 overflow-hidden">
|
||||
<div ref={ref} className='whitespace-nowrap font-bold tracking-wide w-full text-center' style={{fontSize}}>{props.version.name}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
@@ -98,10 +97,20 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
|
||||
return (
|
||||
<NavBarItem onCancel={cancel} progress={downloading ? downloadPercent : 0} isActive={isActive() && !downloading} isDownloading={downloading}>
|
||||
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
|
||||
{renderIcon()}
|
||||
{renderVersionText()}
|
||||
</Link>
|
||||
{props.version.name ? (
|
||||
<Tippy content={props.version.BSVersion} placement="right-end" arrow={false} className="font-bold !bg-main-color-3" duration={[100, 0]} animation="shift-away-subtle">
|
||||
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
|
||||
{renderIcon()}
|
||||
{renderVersionText()}
|
||||
</Link>
|
||||
</Tippy>
|
||||
) : (
|
||||
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
|
||||
{renderIcon()}
|
||||
{renderVersionText()}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
</NavBarItem>
|
||||
)
|
||||
}
|
||||
@@ -7,29 +7,41 @@ import { useObservable } from 'renderer/hooks/use-observable.hook';
|
||||
import { BsManagerIcon } from './bsmanager-icon.component';
|
||||
import { MapsNavBarItem } from './nav-bar-items/maps-nav-bar-item.component';
|
||||
import { NavBarSpliter } from './nav-bar-spliter.component';
|
||||
import { useThemeColor } from 'renderer/hooks/use-theme-color.hook';
|
||||
import Tippy from '@tippyjs/react';
|
||||
import { useTranslation } from 'renderer/hooks/use-translation.hook';
|
||||
import { I18nService } from 'renderer/services/i18n.service';
|
||||
|
||||
export function NavBar() {
|
||||
|
||||
const bsVersionServoce = BSVersionManagerService.getInstance();
|
||||
const bsVersionServoce = BSVersionManagerService.getInstance();
|
||||
|
||||
const installedVersions = useObservable(bsVersionServoce.installedVersions$);
|
||||
const installedVersions = useObservable(bsVersionServoce.installedVersions$);
|
||||
const color = useThemeColor("first-color");
|
||||
const t = useTranslation();
|
||||
|
||||
useObservable(I18nService.getInstance().currentLanguage$)
|
||||
|
||||
return (
|
||||
<nav id='nav-bar' className='z-10 flex flex-col h-full max-h-full items-center p-1 bg-light-main-color-1 dark:bg-main-color-1'>
|
||||
<BsManagerIcon className='relative aspect-square w-16 h-16 mb-3'/>
|
||||
<ol id='versions' className='w-fit max-w-[120px] relative left-[2px] grow overflow-y-hidden scrollbar-track-transparent scrollbar-thin scrollbar-thumb-rounded-full scrollbar-thumb-neutral-900 hover:overflow-y-scroll'>
|
||||
<MapsNavBarItem/>
|
||||
<NavBarSpliter/>
|
||||
<MapsNavBarItem/>
|
||||
<NavBarSpliter/>
|
||||
{installedVersions && installedVersions.map((version) => <BsVersionItem key={JSON.stringify(version)} version={version}/>)}
|
||||
</ol>
|
||||
<NavBarSpliter/>
|
||||
<div className='w-full pb-2 flex flex-col items-center content-center justify-start gap-2'>
|
||||
<Link to="blah">
|
||||
<BsmIcon icon='add' className='text-blue-500 h-[34px]'/>
|
||||
</Link>
|
||||
<Link to="settings">
|
||||
<BsmIcon icon='settings' className='text-blue-500 h-7'/>
|
||||
</Link>
|
||||
<div className='w-full pb-2 flex flex-col items-center content-center justify-start gap-1'>
|
||||
<Tippy placement="right" content={t("nav-bar.add-version")}>
|
||||
<Link className='rounded-md w-9 h-9 flex justify-center items-center hover:bg-light-main-color-3 dark:hover:bg-main-color-3' to="blah">
|
||||
<BsmIcon icon='add' className='text-blue-500 h-[34px]' style={{color}}/>
|
||||
</Link>
|
||||
</Tippy>
|
||||
<Tippy placement="right" content={t("nav-bar.settings")}>
|
||||
<Link className='rounded-md w-9 h-9 flex justify-center items-center hover:bg-light-main-color-3 dark:hover:bg-main-color-3' to="settings">
|
||||
<BsmIcon icon='settings' className='text-blue-500 h-7' style={{color}}/>
|
||||
</Link>
|
||||
</Tippy>
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@ export const NotificationItem = forwardRef(({resolver, notification}: {resolver?
|
||||
const renderImage = (() => {
|
||||
if(notification.type === NotificationType.SUCCESS){ return BeatRunningImg; }
|
||||
if(notification.type === NotificationType.WARNING){ return BeatWaitingImg; }
|
||||
if(notification.type === NotificationType.INFO){ return BeatWaitingImg; }
|
||||
if(notification.type === NotificationType.ERROR){ return BeatConflictImg; }
|
||||
return BeatImpatientImg;
|
||||
})();
|
||||
@@ -23,6 +24,7 @@ export const NotificationItem = forwardRef(({resolver, notification}: {resolver?
|
||||
const renderNeonColors = (() => {
|
||||
if(notification.type === NotificationType.SUCCESS){ return "bg-green-400 shadow-green-400"; }
|
||||
if(notification.type === NotificationType.WARNING){ return "bg-yellow-400 shadow-yellow-400"; }
|
||||
if(notification.type === NotificationType.INFO){ return "bg-blue-500 shadow-blue-500"; }
|
||||
if(notification.type === NotificationType.ERROR){ return "bg-red-500 shadow-red-500"; }
|
||||
return "bg-gray-800 shadow-gray-800 dark:bg-white dark:shadow-white";
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { CSSProperties } from "react";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { Observable } from "rxjs"
|
||||
|
||||
type Props = {
|
||||
value$: Observable<number|string>,
|
||||
className?: string,
|
||||
style?: CSSProperties
|
||||
}
|
||||
|
||||
export default function TextProgressBar({value$, className, style}: Props) {
|
||||
|
||||
const value = useObservable(value$);
|
||||
|
||||
const prefix = typeof value === "number" ? "%" : "";
|
||||
|
||||
return (
|
||||
<span className={className} style={style}>{`${value}${prefix}`}</span>
|
||||
)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export default function SettingColorChooser({color, onChange, pickerClassName}:
|
||||
<span className="z-[1] block h-full w-full border-2 border-white rounded-full" onClick={() => setColorVisible(!colorVisible)} style={{backgroundColor: color}}/>
|
||||
<AnimatePresence>
|
||||
{colorVisible &&
|
||||
<motion.div initial={{opacity: 0}} animate={{opacity: 1}} transition={{duration: .1}} exit={{opacity: 0}} className="fixed flex items-center justify-center translate-y-9 shadow-lg rounded-lg shadow-black">
|
||||
<motion.div initial={{opacity: 0}} animate={{opacity: 1}} transition={{duration: .1}} exit={{opacity: 0}} className="absolute flex items-center justify-center translate-y-9 shadow-lg rounded-lg shadow-black">
|
||||
<div className="absolute w-2/4 aspect-square rotate-45 bg-light-main-color-3 dark:bg-main-color-3 -translate-y-12"/>
|
||||
<HexColorPicker color={color} onChange={onChange} className={pickerClassName} />
|
||||
</motion.div>
|
||||
|
||||
@@ -18,7 +18,7 @@ export function SupportersBlock({className, title, supporters}: Props) {
|
||||
<div className={`mb-10 flex flex-col items-center ${className}`}>
|
||||
<h2 className="uppercase text-3xl font-bold">{t(title)}</h2>
|
||||
<div className="flex justify-center flex-wrap py-5 px-20">
|
||||
{supporters.map(s => <SupporterItem supporter={s} delay={someDelay()}/>)}
|
||||
{supporters.map(s => <SupporterItem key={crypto.randomUUID()} supporter={s} delay={someDelay()}/>)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BsmIcon, BsmIconType } from "../svgs/bsm-icon.component"
|
||||
import { useRef, CSSProperties } from "react";
|
||||
import { useRef, CSSProperties, MouseEvent } from "react";
|
||||
import { BsmImage } from "./bsm-image.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { useClickOutside } from "renderer/hooks/use-click-outside.hook";
|
||||
@@ -45,15 +45,17 @@ export function BsmButton({className, style, imgClassName, iconClassName, icon,
|
||||
|
||||
const renderTypeColor = (() => {
|
||||
if(typeColor === "primary"){ return ""; }
|
||||
if(!typeColor){ return `bg-light-main-color-2 dark:bg-main-color-2 ${!withBar && "hover:brightness-125"}`; }
|
||||
if(!typeColor){ return `bg-light-main-color-2 dark:bg-main-color-2 ${(!withBar && !disabled) && "hover:brightness-125"}`; }
|
||||
if(typeColor === "cancel"){ return "bg-gray-500"; }
|
||||
if(typeColor === "error"){ return "bg-red-500"; }
|
||||
if(typeColor === "success"){ return "bg-green-500"; }
|
||||
return "";
|
||||
})();
|
||||
|
||||
const handleClick = (e: MouseEvent) => !disabled && onClick?.(e);
|
||||
|
||||
return (
|
||||
<div ref={ref} onClick={onClick} title={t(title)} className={`${className} overflow-hidden cursor-pointer group ${(!withBar && !disabled && (!!typeColor || !!color)) && "hover:brightness-[1.15]"} ${disabled && "brightness-75 cursor-not-allowed"} ${renderTypeColor}`} style={{...style, backgroundColor: primaryColor || color}}>
|
||||
<div ref={ref} onClick={handleClick} title={t(title)} className={`${className} overflow-hidden cursor-pointer group ${(!withBar && !disabled && (!!typeColor || !!color)) && "hover:brightness-[1.15]"} ${disabled && "brightness-75 cursor-not-allowed"} ${renderTypeColor}`} style={{...style, backgroundColor: primaryColor || color}}>
|
||||
{ image && <BsmImage image={image} className={imgClassName}/> }
|
||||
{ icon && <BsmIcon icon={icon} className={iconClassName ?? "h-full w-full text-gray-800 dark:text-white"} style={{color: iconColor}}/> }
|
||||
{text && (type === "submit" ? <button type="submit" className={textClassName || "h-full w-full"} style={{...(!!textColor && {color: textColor})}}>{t(text)}</button> : <span className={textClassName} style={{...(!!textColor && {color: `${textColor}`})}}>{t(text)}</span>)}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { BsmIcon } from "../svgs/bsm-icon.component"
|
||||
import { useThemeColor } from "renderer/hooks/use-theme-color.hook";
|
||||
import { getCorrectTextColor } from "renderer/helpers/correct-text-color"
|
||||
import { GlowEffect } from "./glow-effect.component";
|
||||
import { motion } from "framer-motion";
|
||||
import { useState } from "react";
|
||||
|
||||
type Props = {className?:string, checked?: boolean, onChange?: (val: boolean) => void, disabled?: boolean}
|
||||
|
||||
export function BsmCheckbox({className, checked, onChange, disabled} : Props) {
|
||||
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const checkedColor = useThemeColor("first-color");
|
||||
const iconColor = getCorrectTextColor(checkedColor);
|
||||
|
||||
@@ -15,12 +19,12 @@ export function BsmCheckbox({className, checked, onChange, disabled} : Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`${className} group-one`}>
|
||||
{!disabled && <span className="glow-on-hover !w-[calc(100%+6px)] !h-[calc(100%+6px)] !-top-[3px] !-left-[3px] group-one-hover:opacity-100"/>}
|
||||
<motion.div className={`${className} group-one`} onHoverStart={() => setHovered(true)} onHoverEnd={() => setHovered(false)}>
|
||||
<GlowEffect visible={!disabled && hovered} className="!w-[calc(100%+6px)] !h-[calc(100%+6px)] !-top-[3px] !-left-[3px]"/>
|
||||
|
||||
<span className={`w-full h-full flex items-center justify-center rounded-md border-2 border-current overflow-hidden bg-light-main-color-3 dark:bg-main-color-1 ${disabled ? "opacity-30 cursor-not-allowed" : "cursor-pointer"}`} onClickCapture={e => {e.stopPropagation(); handleClick()}}>
|
||||
<BsmIcon className="w-full h-full" icon="check" style={{color: iconColor, backgroundColor: checkedColor, visibility: checked ? "visible" : "hidden"}}/>
|
||||
</span>
|
||||
</div>
|
||||
</motion.div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ export const BsmImage = forwardRef(({className, image, errorImage, placeholder,
|
||||
|
||||
return (
|
||||
// @ts-ignore
|
||||
<img ref={ref} title={title} className={className} src={image} loading={loading} onLoad={handleLoaded} onError={handleError} style={styles} onClick={(e) => onClick?.(e)} alt=" "/>
|
||||
<img ref={ref} title={title} className={className} src={image} loading={loading} onLoad={handleLoaded} onError={handleError} style={styles} onClick={(e) => onClick?.(e)} alt=" " decoding="async"/>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -11,9 +11,10 @@ type Props = {
|
||||
max: number,
|
||||
step?: number,
|
||||
renderLabel?: (value: number) => JSX.Element,
|
||||
colors?: string[]
|
||||
}
|
||||
|
||||
export function BsmRange({colorType = "first-color", values, onChange, onFinalChange, min, max, renderLabel, step = 1} : Props) {
|
||||
export function BsmRange({colorType = "first-color", values, onChange, onFinalChange, min, max, renderLabel, step = 1, colors} : Props) {
|
||||
|
||||
const color = useThemeColor(colorType);
|
||||
const labelTextColor = getCorrectTextColor(color);
|
||||
@@ -35,10 +36,10 @@ export function BsmRange({colorType = "first-color", values, onChange, onFinalCh
|
||||
style={{
|
||||
...props.style,
|
||||
background: getTrackBackground({
|
||||
values: values,
|
||||
colors: ["#ccc", color, "#ccc"],
|
||||
min: min,
|
||||
max: max
|
||||
values,
|
||||
colors: colors ?? ["#ccc", color, "#ccc"],
|
||||
min,
|
||||
max
|
||||
}),
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AnimatePresence, motion } from "framer-motion"
|
||||
|
||||
type Props = {
|
||||
visible?: boolean,
|
||||
className?: string
|
||||
}
|
||||
|
||||
export function GlowEffect({visible, className}: Props) {
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{visible && <motion.div transition={{duration: .1}} initial={{opacity: 0}} animate={{opacity: 1}} exit={{opacity: 0}} className={`${className} glow-on-hover`}/>}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@ export function BsmIframeView() {
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{iframeUrl && (
|
||||
<div className="top-0 absolute w-screen h-screen flex content-center items-center justify-center z-50">
|
||||
<div className="top-0 absolute w-screen h-screen flex content-center items-center justify-center z-[150]">
|
||||
<motion.span className="absolute w-full h-full bg-black top-0 right-0" initial={{opacity: 0}} animate={{opacity: .60}} exit={{opacity: 0}} transition={{duration: .2}}/>
|
||||
<motion.div ref={ref} className="z-[1] w-[calc(100vw-250px)] h-[calc(100vh-250px)] shadow-black shadow-md rounded-md overflow-hidden bg-black" initial={{y: "100vh"}} animate={{y: 0}} exit={{y: "100vh"}}>
|
||||
<iframe className="w-full h-full" src={iframeUrl}/>
|
||||
@@ -46,11 +46,16 @@ import { FilterIcon } from "./icons/filter-icon.component";
|
||||
import DiscordIcon from "./icons/discord-icon.component";
|
||||
import { TwitterIcon } from "./icons/twitter-icon.component";
|
||||
import { Mee6Icon } from "./icons/mee6-icon.component";
|
||||
import { InfoIcon } from "./icons/info-icon.component";
|
||||
import { SyncIcon } from "./icons/sync-icon.component";
|
||||
import { VolumeUpIcon } from "./icons/volume-up-icon.component";
|
||||
import { VolumeOffIcon } from "./icons/volume-off-icon.component";
|
||||
import { VolumeDownIcon } from "./icons/volume-down-icon.component";
|
||||
|
||||
export type BsmIconType = BsvMapCharacteristic | (
|
||||
"settings"|"trash"|"favorite"|"folder"|"bsNote"|"check"|"three-dots"|"twitch"|"eye"|"play"|"checkCircleIcon"|"discord"|
|
||||
"terminal"|"desktop"|"oculus"|"add"|"cross"|"task"|"github"|"close"|"thumbUpFill"|"timerFill"|"pause"|"twitter"|
|
||||
"copy"|"steam"|"edit"|"export"|"patreon"|"search"|"bsMapDifficulty"|"link"|"unlink"|"download"|"filter"|"mee6"|
|
||||
"settings"|"trash"|"favorite"|"folder"|"bsNote"|"check"|"three-dots"|"twitch"|"eye"|"play"|"checkCircleIcon"|"discord"|"info"|
|
||||
"terminal"|"desktop"|"oculus"|"add"|"cross"|"task"|"github"|"close"|"thumbUpFill"|"timerFill"|"pause"|"twitter"|"sync"|
|
||||
"copy"|"steam"|"edit"|"export"|"patreon"|"search"|"bsMapDifficulty"|"link"|"unlink"|"download"|"filter"|"mee6"|"volume-up"|"volume-off"|"volume-down"|
|
||||
"fr-FR-flag"|"es-ES-flag"|"en-US-flag"|"en-EN-flag"
|
||||
);
|
||||
|
||||
@@ -103,6 +108,11 @@ export const BsmIcon = memo(({className, icon, style}: {className?: string, icon
|
||||
if(icon === "discord"){ return <DiscordIcon className={className} style={style}/> }
|
||||
if(icon === "twitter"){ return <TwitterIcon className={className} style={style}/> }
|
||||
if(icon === "mee6"){ return <Mee6Icon className={className} style={style}/> }
|
||||
if(icon === "info"){ return <InfoIcon className={className} style={style}/> }
|
||||
if(icon === "sync"){ return <SyncIcon className={className} style={style}/> }
|
||||
if(icon === "volume-up"){ return <VolumeUpIcon className={className} style={style}/> }
|
||||
if(icon === "volume-down"){ return <VolumeDownIcon className={className} style={style}/> }
|
||||
if(icon === "volume-off"){ return <VolumeOffIcon className={className} style={style}/> }
|
||||
return <TrashIcon className={className} style={style}/>
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
export function InfoIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} viewBox="0 0 400 400">
|
||||
<path stroke="none" fill="currentColor" fillRule="evenodd" d="M225 1.3c-34.8 9.2-48.5 49.6-25.4 75 30.8 34 89 14.6 88.8-29.8 0-31-31.9-53.7-63.4-45.3m-45 134.4c-13.6 2.1-31.1 7.3-52.3 15.5l-10.9 4.2L114 167c-1.5 6.4-2.7 11.7-2.6 11.9.1.1 4-1 8.7-2.5 23.6-7.6 42.2-5.7 47.6 5 6.3 12.3 4.2 25.2-14.4 91.4-6 21.2-11.7 42.8-12.7 48-10 51.7 11.2 78.7 62.1 78.9 23 0 26-.7 61-14.1L278 380l2.8-11.7c3.3-13.6 3.5-12.5-1.8-10.5-24.3 9.3-48.5 6.9-53.6-5.3-5.2-12.4-3-25.6 14.5-87.8 13.3-47 12.5-44.1 13.8-52.7 6.5-42.6-6-66.5-38.8-74.6-6.5-1.6-28.5-2.8-34.7-1.9"/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { CSSProperties } from "react";
|
||||
|
||||
export function SettingIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" height="40" width="40">
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
||||
<path fill="currentColor" d="M16.5 35.833 15.792 30.792Q15 30.542 14.104 30.042Q13.208 29.542 12.542 28.958L7.875 31.042L4.375 24.875L8.542 21.792Q8.458 21.375 8.438 20.896Q8.417 20.417 8.417 20Q8.417 19.625 8.438 19.146Q8.458 18.667 8.542 18.208L4.375 15.125L7.875 9L12.542 11.042Q13.25 10.458 14.125 9.979Q15 9.5 15.792 9.208L16.5 4.167H23.5L24.208 9.208Q25.042 9.542 25.875 10Q26.708 10.458 27.375 11.042L32.125 9L35.625 15.125L31.375 18.208Q31.5 18.667 31.521 19.125Q31.542 19.583 31.542 20Q31.542 20.417 31.5 20.854Q31.458 21.292 31.375 21.792L35.583 24.875L32.083 31.042L27.375 28.917Q26.667 29.542 25.854 30.042Q25.042 30.542 24.208 30.792L23.5 35.833ZM19.958 24.792Q21.958 24.792 23.375 23.396Q24.792 22 24.792 20Q24.792 18 23.375 16.604Q21.958 15.208 19.958 15.208Q17.958 15.208 16.562 16.604Q15.167 18 15.167 20Q15.167 22 16.562 23.396Q17.958 24.792 19.958 24.792Z"/>
|
||||
</svg>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
export function SyncIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
||||
<path fill="currentColor" d="M25.625 32.542q-.917.416-1.667-.084t-.75-1.625q0-.5.354-1 .355-.5.855-.75 2.666-1.25 4.187-3.75 1.521-2.5 1.521-5.458 0-1.833-.854-3.708-.854-1.875-2.313-3.375l-.791-.709v2.75q0 .667-.459 1.105-.458.437-1.083.437-.667 0-1.104-.437-.438-.438-.438-1.105V8.125q0-.792.542-1.312.542-.521 1.292-.521h6.75q.666 0 1.104.437.437.438.437 1.104 0 .667-.437 1.084-.438.416-1.104.416h-3l.375.417q2.416 2.292 3.604 4.938 1.187 2.645 1.187 5.187 0 4.208-2.229 7.583t-5.979 5.084ZM8.417 33.708q-.667 0-1.084-.437-.416-.438-.416-1.104 0-.667.416-1.084.417-.416 1.084-.416h2.958L11 30.333q-2.5-2.208-3.667-4.729-1.166-2.521-1.166-5.479 0-4.208 2.271-7.604 2.27-3.396 5.979-5.063.916-.416 1.645.105.73.52.73 1.604 0 .5-.334 1-.333.5-.833.75-2.625 1.25-4.187 3.75-1.563 2.5-1.563 5.458 0 2.25.854 4.042.854 1.791 2.396 3.208l.792.542v-2.75q0-.667.458-1.105.458-.437 1.125-.437.625 0 1.062.437.438.438.438 1.105v6.708q0 .792-.542 1.313-.541.52-1.291.52Z"/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -4,7 +4,7 @@ export function TwitterIcon(props: {className?: string, style?: CSSProperties})
|
||||
return (
|
||||
<svg className={props.className} style={props.style} viewBox="0 0 24 24" fill="currentColor">
|
||||
<g>
|
||||
<path d="M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0 .364.042.718.12 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823 3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254 0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z"></path>
|
||||
<path d="M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0 .364.042.718.12 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823 3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254 0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z"/>
|
||||
</g>
|
||||
</svg>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
export function VolumeDownIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 96 960 960" fill="currentColor">
|
||||
<path d="M251.283 675.999q-13.564 0-22.423-8.859-8.859-8.859-8.859-22.423V507.283q0-13.564 8.859-22.423 8.859-8.859 22.423-8.859h117.179L486.794 357.67q14.769-14.769 33.987-6.91 19.218 7.858 19.218 28.781v392.661q0 21.18-19.218 29.038-19.218 7.859-33.987-6.91L368.462 675.999H251.283Zm374.358 49.949V424.463q43.05 19.102 68.704 60.551 25.654 41.448 25.654 90.986 0 50.205-25.654 90.525-25.654 40.32-68.704 59.423ZM489.744 429.436l-99.129 96.82H270.256v99.488h120.359l99.129 97.23V429.436ZM378.923 576Z"/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
export function VolumeOffIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 96 960 960" fill="currentColor">
|
||||
<path d="M770.974 963.435 663.179 855.64q-15.436 9.948-31.423 18.512-15.987 8.564-33.244 15-12.845 4.846-23.909-3.397-11.064-8.243-11.064-22.756 0-6.82 4.013-12.064 4.012-5.243 10.243-7.397 12.872-4.487 25.436-10.41t24-13.692L468.153 659.948v112.254q0 21.18-19.218 29.038-19.217 7.859-33.986-6.91L296.617 675.999H179.438q-13.564 0-22.423-8.859-8.859-8.859-8.859-22.423V507.283q0-13.564 8.859-22.423 8.859-8.859 22.423-8.859H283.54L94.155 286.36q-7.23-7.231-7.218-17.705.013-10.474 7.628-18.089 7.616-7.359 17.692-7.359 10.077 0 17.692 7.359l677.485 677.075q7.231 7.231 7.295 17.705.064 10.474-7.295 18.089-7.615 7.615-18.23 7.615t-18.23-7.615ZM598.512 260.591q97.769 38.231 157.551 123.423Q815.845 469.206 815.845 575q0 51.795-15.449 100.09t-44.398 90.217l-35.819-35.819q22.59-34.026 34-73.193Q765.59 617.129 765.59 575q0-91.743-51.308-165.628-51.308-73.885-136.487-103.321-6.82-2.153-10.538-7.692-3.718-5.538-3.718-12.358 0-14.051 11.269-22.025 11.269-7.974 23.704-3.385ZM376.257 568.718Zm257.28 74.129-69.998-69.999V427.847q40.461 22 62.538 61.961Q648.153 529.77 648.153 576q0 17.693-3.654 34.5-3.654 16.808-10.962 32.347ZM468.153 477.463l-86.306-86.692 33.102-33.101q14.769-14.769 33.986-6.782 19.218 7.987 19.218 28.653v97.922Zm-50.255 247.819V610.359l-84.103-84.103H198.411v99.488H318.36l99.538 99.538Z"/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
export function VolumeUpIcon(props: {className?: string, style?: CSSProperties}) {
|
||||
return (
|
||||
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 96 960 960" fill="currentColor">
|
||||
<path d="M596.512 889.152q-12.846 4.846-23.91-3.416-11.063-8.263-11.063-22.794 0-6.763 4.012-12.007 4.013-5.243 10.244-7.397 84.769-32 136.282-104.936Q763.589 665.667 763.589 575t-51.512-163.808q-51.513-73.141-136.282-104.73-6.821-2.154-10.539-7.965-3.717-5.812-3.717-12.587 0-13.96 11.268-21.934 11.269-7.974 23.705-3.385 97.64 38.231 157.486 123.339 59.846 85.107 59.846 191.07t-59.846 191.07q-59.846 85.108-157.486 123.082ZM177.438 675.999q-13.468 0-22.375-8.907t-8.907-22.375V507.283q0-13.468 8.907-22.375t22.375-8.907h117.178L412.948 357.67q14.769-14.769 33.987-6.722 19.218 8.047 19.218 28.593v392.661q0 20.803-19.218 28.85t-33.987-6.722L294.616 675.999H177.438Zm374.357 49.949V424.463q43.051 19.102 68.704 60.551 25.654 41.448 25.654 90.986 0 50.205-25.654 90.525-25.653 40.32-68.704 59.423ZM415.898 429.436l-99.128 96.82H196.411v99.488H316.77l99.128 97.23V429.436ZM318.872 576Z"/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,37 +1,54 @@
|
||||
import { useState } from 'react';
|
||||
import { useObservable } from 'renderer/hooks/use-observable.hook';
|
||||
import { useThemeColor } from 'renderer/hooks/use-theme-color.hook';
|
||||
import { AudioPlayerService } from 'renderer/services/audio-player.service';
|
||||
import { IpcService } from 'renderer/services/ipc.service';
|
||||
import { WindowManagerService } from 'renderer/services/window-manager.service';
|
||||
import { AppWindow } from 'shared/models/window-manager/app-window.model';
|
||||
import { BsmButton } from '../shared/bsm-button.component';
|
||||
import { BsmRange } from '../shared/bsm-range.component';
|
||||
import { BsmIconType } from '../svgs/bsm-icon.component';
|
||||
import './title-bar.component.css'
|
||||
|
||||
export default function TitleBar({template = "index.html"} : {template: AppWindow}) {
|
||||
|
||||
const ipcService = IpcService.getInstance();
|
||||
const windows = WindowManagerService.getInstance();
|
||||
const ipcService = IpcService.getInstance();
|
||||
const windows = WindowManagerService.getInstance();
|
||||
const audio = AudioPlayerService.getInstance();
|
||||
|
||||
const [maximized, setMaximized] = useState(false);
|
||||
const volume = useObservable(audio.volume$, audio.volume);
|
||||
const playing = useObservable(audio.playing$);
|
||||
const color = useThemeColor("first-color");
|
||||
|
||||
const closeWindow = () => {
|
||||
return windows.close(template);
|
||||
const [maximized, setMaximized] = useState(false);
|
||||
|
||||
const closeWindow = () => {
|
||||
return windows.close(template);
|
||||
}
|
||||
|
||||
const maximizeWindow = () => {
|
||||
ipcService.sendLazy('window.maximize');
|
||||
}
|
||||
|
||||
const maximizeWindow = () => {
|
||||
ipcService.sendLazy('window.maximize');
|
||||
}
|
||||
const minimizeWindow = () => {
|
||||
ipcService.sendLazy('window.minimize');
|
||||
}
|
||||
|
||||
const minimizeWindow = () => {
|
||||
ipcService.sendLazy('window.minimize');
|
||||
}
|
||||
const resetWindow = () => {
|
||||
ipcService.sendLazy('window.reset');
|
||||
}
|
||||
|
||||
const resetWindow = () => {
|
||||
ipcService.sendLazy('window.reset');
|
||||
}
|
||||
const toogleMaximize = () => {
|
||||
if(maximized){ resetWindow(); }
|
||||
else{ maximizeWindow(); }
|
||||
setMaximized(!maximized);
|
||||
}
|
||||
|
||||
const toogleMaximize = () => {
|
||||
if(maximized){ resetWindow(); }
|
||||
else{ maximizeWindow(); }
|
||||
setMaximized(!maximized);
|
||||
}
|
||||
const volumeIcon: BsmIconType = (() => {
|
||||
if(volume.muted || !volume.volume){ return "volume-off"; }
|
||||
if(volume.volume < .5){ return "volume-down"; }
|
||||
return "volume-up";
|
||||
})()
|
||||
|
||||
if(template === "index.html"){
|
||||
|
||||
@@ -42,7 +59,13 @@ export default function TitleBar({template = "index.html"} : {template: AppWindo
|
||||
<span className='text-gray-800 dark:text-gray-100 font-bold text-xs italic'>BSManager</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="window-controls" className="h-full flex shrink-0">
|
||||
<div id="window-controls" className="h-full flex shrink-0 items-center">
|
||||
<div className='h-full text-gray-800 dark:text-gray-200 pr-1 cursor-pointer flex flex-row justify-end items-center gap-2 group pl-5'>
|
||||
<div className='shrink-0 w-0 overflow-hidden transition-all group-hover:w-16 group-hover:overflow-visible group-active:w-16 group-active:overflow-visible text-main-color-3'>
|
||||
<BsmRange min={0} max={1} step={.01} values={[volume.muted ? 0 : volume.volume]} colors={[color, "currentColor"]} onChange={val => audio.setVolume(val[0])} onFinalChange={val => audio.setFinalVolume(val[0])}/>
|
||||
</div>
|
||||
<BsmButton className='shrink-0 h-[23px] w-[23px] aspect-square !bg-transparent flex items-start' iconClassName={volumeIcon === "volume-down" ? "-translate-x-[1.8px]" : null} icon={volumeIcon} withBar={false} onClick={() => audio.toggleMute()}/>
|
||||
</div>
|
||||
<div onClick={minimizeWindow} className="text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-[#4F545C] cursor-pointer w-11 h-full shrink-0 flex justify-center items-center" id="min-button" >
|
||||
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><rect fill="currentColor" width="10" height="1" x="1" y="6"> </rect></svg>
|
||||
</div>
|
||||
|
||||
+21
-6
@@ -1,18 +1,33 @@
|
||||
import Tippy from "@tippyjs/react";
|
||||
import { GlowEffect } from "renderer/components/shared/glow-effect.component";
|
||||
import { BsmIcon, BsmIconType } from "renderer/components/svgs/bsm-icon.component"
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
|
||||
type props = {onClick: (active: boolean) => void, active: boolean, text: string, icon: BsmIconType}
|
||||
type props = {
|
||||
onClick: (active: boolean) => void,
|
||||
active: boolean,
|
||||
text: string,
|
||||
icon: BsmIconType,
|
||||
infoText?: string,
|
||||
}
|
||||
|
||||
export function LaunchModToogle({onClick, active, text, icon}: props) {
|
||||
export function LaunchModToogle({onClick, active, text, icon, infoText}: props) {
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
return (
|
||||
<div className={`relative rounded-full cursor-pointer group active:scale-95 transition-transform ${!active && "shadow-md shadow-black"}`} onClick={() => onClick(!active)}>
|
||||
<div className={`absolute glow-on-hover !rounded-full ${active && "!opacity-100 blur-[2px]"}`}/>
|
||||
<div className='w-full h-full px-6 flex justify-center items-center bg-light-main-color-2 dark:bg-main-color-2 p-3 rounded-full text-gray-800 dark:text-white group-hover:bg-light-main-color-1 dark:group-hover:bg-main-color-1'>
|
||||
<BsmIcon icon={icon} className='mr-1 h-7 text-gray-800 dark:text-white'/>
|
||||
<span className='w-fit min-w-fit h-full text-lg font-bold uppercase tracking-wide italic'>{t(text)}</span>
|
||||
<GlowEffect visible={active} className="absolute !rounded-full blur-[2px]"/>
|
||||
<div className='w-full h-full px-6 flex gap-1.5 justify-center items-center bg-light-main-color-2 dark:bg-main-color-2 p-3 rounded-full text-gray-800 dark:text-white group-hover:bg-light-main-color-1 dark:group-hover:bg-main-color-1'>
|
||||
<BsmIcon icon={icon} className='h-7 text-gray-800 dark:text-white'/>
|
||||
<span className='w-fit min-w-fit text-lg font-bold uppercase tracking-wide italic '>{t(text)}</span>
|
||||
{infoText && (
|
||||
<Tippy content={t(infoText)} placement="bottom" delay={[400, 0]}>
|
||||
<div className="h-[25px] w-[25px] p-1.5 rounded-full cursor-help bg-light-main-color-1 dark:bg-main-color-3 hover:brightness-110">
|
||||
<BsmIcon className="w-full h-full" icon="info"/>
|
||||
</div>
|
||||
</Tippy>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import { ChangeEvent, useEffect, useState } from "react";
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { BSLauncherService, LaunchMods } from "renderer/services/bs-launcher.service";
|
||||
import { ConfigurationService } from "renderer/services/configuration.service";
|
||||
import { BSVersion } from "shared/bs-version.interface"
|
||||
@@ -10,41 +12,58 @@ type Props = {version: BSVersion};
|
||||
|
||||
export function LaunchSlide({version}: Props) {
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
const configService = ConfigurationService.getInstance();
|
||||
const bsLauncherService = BSLauncherService.getInstance();
|
||||
|
||||
const [oculusMode, setOculusMode] = useState(!!configService.get<boolean>(LaunchMods.OCULUS_MOD));
|
||||
const [desktopMode, setDesktopMode] = useState(!!configService.get<boolean>(LaunchMods.DESKTOP_MOD));
|
||||
const [debugMode, setDebugMode] = useState(!!configService.get<boolean>(LaunchMods.DEBUG_MOD));
|
||||
const [advancedLaunch, setAdvancedLaunch] = useState(false);
|
||||
const [additionalArgsString, setAdditionalArgsString] = useState<string>(configService.get<string>("additionnal-args") || "");
|
||||
|
||||
const launchState = useObservable(bsLauncherService.launchState$);
|
||||
|
||||
useEffect(() => {
|
||||
configService.set("additionnal-args", additionalArgsString);
|
||||
}, [additionalArgsString]);
|
||||
|
||||
const setMode = (mode: LaunchMods, value: boolean) => {
|
||||
if(mode === LaunchMods.DEBUG_MOD){ setDebugMode(value); }
|
||||
if(mode === LaunchMods.DEBUG_MOD){
|
||||
setDebugMode(value);
|
||||
}
|
||||
else if(mode === LaunchMods.OCULUS_MOD){
|
||||
setOculusMode(value);
|
||||
setDesktopMode(false);
|
||||
configService.set(LaunchMods.DESKTOP_MOD, false);
|
||||
setOculusMode(value);
|
||||
}
|
||||
else if(mode === LaunchMods.DESKTOP_MOD){
|
||||
setDesktopMode(value);
|
||||
setOculusMode(false);
|
||||
configService.set(LaunchMods.OCULUS_MOD, false);
|
||||
setDesktopMode(value);
|
||||
}
|
||||
configService.set(mode, value);
|
||||
}
|
||||
|
||||
const launch = () => bsLauncherService.launch(version, version.oculus ? false : oculusMode, desktopMode, debugMode)
|
||||
const handleAdditionalArgsChange = (e: ChangeEvent<HTMLInputElement>) => setAdditionalArgsString(() => e.target.value);
|
||||
|
||||
const launch = () => {
|
||||
const additionalArgs = advancedLaunch ? additionalArgsString.split(";").map(arg => arg.trim()).filter(arg => arg.length > 0) : undefined;
|
||||
bsLauncherService.launch(version, version.oculus ? false : oculusMode, desktopMode, debugMode, additionalArgs);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full shrink-0 items-center relative flex flex-col justify-start">
|
||||
<div className='grid grid-flow-col gap-6'>
|
||||
{!version.oculus && <LaunchModToogle icon='oculus' onClick={() => setMode(LaunchMods.OCULUS_MOD, !oculusMode)} active={oculusMode} text="pages.version-viewer.launch-mods.oculus"/>}
|
||||
<LaunchModToogle icon='desktop' onClick={() => setMode(LaunchMods.DESKTOP_MOD, !desktopMode)} active={desktopMode} text="pages.version-viewer.launch-mods.desktop"/>
|
||||
<LaunchModToogle icon='terminal' onClick={() => setMode(LaunchMods.DEBUG_MOD, !debugMode)} active={debugMode} text="pages.version-viewer.launch-mods.debug"/>
|
||||
{!version.oculus && <LaunchModToogle infoText="pages.version-viewer.launch-mods.oculus-description" icon='oculus' onClick={() => setMode(LaunchMods.OCULUS_MOD, !oculusMode)} active={oculusMode} text="pages.version-viewer.launch-mods.oculus"/>}
|
||||
<LaunchModToogle infoText="pages.version-viewer.launch-mods.desktop-description" icon='desktop' onClick={() => setMode(LaunchMods.DESKTOP_MOD, !desktopMode)} active={desktopMode} text="pages.version-viewer.launch-mods.desktop"/>
|
||||
<LaunchModToogle infoText="pages.version-viewer.launch-mods.debug-description" icon='terminal' onClick={() => setMode(LaunchMods.DEBUG_MOD, !debugMode)} active={debugMode} text="pages.version-viewer.launch-mods.debug"/>
|
||||
</div>
|
||||
<div className="pt-4 w-2/3 flex flex-col items-center gap-3">
|
||||
<BsmButton className="rounded-full w-fit text-lg py-1 px-7 shadow-md shadow-black bg-light-main-color-2 dark:bg-main-color-2 text-gray-800 dark:text-white" text="pages.version-viewer.launch-mods.advanced-launch.button" withBar={false} onClick={e => {e.preventDefault(); setAdvancedLaunch(prev => !prev)}}/>
|
||||
<motion.div className="bg-light-main-color-2 dark:bg-main-color-2 h-9 rounded-full overflow-hidden flex items-center justify-center" initial={{width: "0px"}} animate={{width: advancedLaunch ? "100%" : "0px"}}>
|
||||
<input className="w-[calc(100%-12px)] h-[calc(100%-12px)] bg-light-main-color-1 dark:bg-main-color-1 text-black dark:text-white rounded-full outline-none text-center" type="text" placeholder={t("pages.version-viewer.launch-mods.advanced-launch.placeholder")} value={additionalArgsString} onChange={handleAdditionalArgsChange}/>
|
||||
</motion.div>
|
||||
</div>
|
||||
<div className='grow flex justify-center items-center'>
|
||||
<BsmButton onClick={launch} active={JSON.stringify(version) === JSON.stringify(launchState)} className='relative text-5xl text-gray-800 dark:text-gray-200 font-bold tracking-wide pt-1 pb-3 px-7 rounded-lg shadow-md italic shadow-black active:scale-90 transition-transform' text="misc.launch"/>
|
||||
<BsmButton onClick={launch} active={JSON.stringify(version) === JSON.stringify(launchState)} className='relative -translate-y-1/2 text-5xl text-gray-800 dark:text-gray-200 font-bold tracking-wide pt-1 pb-3 px-7 rounded-lg shadow-md italic shadow-black active:scale-90 transition-transform' text="misc.launch"/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -69,16 +69,14 @@ export function ModsGrid({modsMap, installed, modsSelected, onModChange, moreInf
|
||||
]}/>
|
||||
</span>
|
||||
|
||||
{
|
||||
Array.from(modsMap.keys()).map(key => modsMap.get(key).some(mod => mod.name.toLowerCase().includes(filter)) && (
|
||||
{Array.from(modsMap.keys()).map(key => modsMap.get(key).some(mod => mod.name.toLowerCase().includes(filter)) && (
|
||||
<ul key={key} className="contents">
|
||||
<h2 className="col-span-full py-1 font-bold pl-3">{key}</h2>
|
||||
{modsMap.get(key).map(mod => mod.name.toLowerCase().includes(filter) && (
|
||||
<ModItem key={mod.name} className="contents bg-light-main-color-3 dark:bg-main-color-1 text-main-color-1 dark:text-light-main-color-1 hover:cursor-pointer" mod={mod} installedVersion={installedModVersion(key, mod)} isDependency={isDependency(mod)} isSelected={isSelected(mod)} onChange={(val) => onModChange(val, mod)} onWantInfo={onWantInfos} wantInfo={mod.name === moreInfoMod?.name}/>
|
||||
))}
|
||||
</ul>
|
||||
))
|
||||
}
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ConfigurationService } from "renderer/services/configuration.service";
|
||||
import { DefaultConfigKey } from "renderer/config/default-configuration.config";
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import BeatWaitingImg from "../../../../../../assets/images/apngs/beat-waiting.png"
|
||||
import BeatConflictImg from "../../../../../../assets/images/apngs/beat-conflict.png"
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { skip, filter } from "rxjs/operators";
|
||||
import { Subscription } from "rxjs";
|
||||
@@ -15,6 +16,7 @@ import { LinkOpenerService } from "renderer/services/link-opener.service";
|
||||
import { useInView } from "framer-motion";
|
||||
import { ModalExitCode, ModalService } from "renderer/services/modale.service";
|
||||
import { ModsDisclaimerModal } from "renderer/components/modal/modal-types/mods-disclaimer-modal.component";
|
||||
import { OsDiagnosticService } from "renderer/services/os-diagnostic.service";
|
||||
|
||||
export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, onDisclamerDecline: () => void}) {
|
||||
|
||||
@@ -24,6 +26,7 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
const configService = ConfigurationService.getInstance();
|
||||
const linkOpener = LinkOpenerService.getInstance();
|
||||
const modals = ModalService.getInsance();
|
||||
const os = OsDiagnosticService.getInstance();
|
||||
|
||||
const ref = useRef(null);
|
||||
const isVisible = useInView(ref, {amount: .5});
|
||||
@@ -31,11 +34,13 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
const [modsInstalled, setModsInstalled] = useState(null as Map<string, Mod[]>);
|
||||
const [modsSelected, setModsSelected] = useState([] as Mod[]);
|
||||
const [moreInfoMod, setMoreInfoMod] = useState(null as Mod);
|
||||
const isOnline = useObservable(os.isOnline$);
|
||||
const installing = useObservable(modsManager.isInstalling$);
|
||||
const t = useTranslation();
|
||||
|
||||
const downloadRef = useRef(null);
|
||||
const [downloadWith, setDownloadWidth] = useState(0);
|
||||
|
||||
|
||||
const modsToCategoryMap = (mods: Mod[]): Map<string, Mod[]> => {
|
||||
if(!mods){ return new Map<string, Mod[]>(); }
|
||||
@@ -69,6 +74,8 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
}
|
||||
|
||||
const loadMods = () => {
|
||||
if(os.isOffline){ return; }
|
||||
|
||||
Promise.all([
|
||||
modsManager.getAvailableMods(version),
|
||||
modsManager.getInstalledMods(version)
|
||||
@@ -84,7 +91,7 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
|
||||
const subs: Subscription[] = [];
|
||||
|
||||
if(isVisible){
|
||||
if(isVisible && isOnline){
|
||||
|
||||
const promise = new Promise<boolean>(async resolve => {
|
||||
|
||||
@@ -115,7 +122,7 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
subs.forEach(s => s.unsubscribe());
|
||||
}
|
||||
|
||||
}, [isVisible, version]);
|
||||
}, [isVisible, isOnline, version]);
|
||||
|
||||
|
||||
useLayoutEffect(() => {
|
||||
@@ -128,9 +135,9 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
return (
|
||||
<div ref={ref} className='shrink-0 w-full h-full px-8 pb-7 flex justify-center'>
|
||||
<div className='relative flex flex-col grow-0 bg-light-main-color-2 dark:bg-main-color-2 h-full w-full rounded-md shadow-black shadow-center overflow-hidden'>
|
||||
{modsAvailable ? (
|
||||
{isOnline && modsAvailable ? (
|
||||
<>
|
||||
<div className="overflow-scroll w-full min-h-0 scrollbar-thin scrollbar-thumb-neutral-900 scrollbar-thumb-rounded-full">
|
||||
<div className="grow overflow-scroll w-full min-h-0 scrollbar-thin scrollbar-thumb-neutral-900 scrollbar-thumb-rounded-full">
|
||||
<ModsGrid modsMap={modsAvailable} installed={modsInstalled} modsSelected={modsSelected} onModChange={handleModChange} moreInfoMod={moreInfoMod} onWantInfos={handleMoreInfo}/>
|
||||
</div>
|
||||
<div className="h-10 shrink-0 flex items-center justify-between px-3">
|
||||
@@ -141,9 +148,9 @@ export function ModsSlide({version, onDisclamerDecline}: {version: BSVersion, on
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="w-full h-full flex flex-col items-center justify-center">
|
||||
<img className="w-32 h-32 spin-loading" src={BeatWaitingImg} alt=" "/>
|
||||
<span className="text-xl mt-3 h-0 italic">{t("pages.version-viewer.mods.loading-mods")}</span>
|
||||
<div className="w-full h-full flex flex-col items-center justify-center text-gray-800 dark:text-gray-200">
|
||||
<img className={`w-32 h-32 ${isOnline && "spin-loading"}`} src={isOnline ? BeatWaitingImg : BeatConflictImg} alt=" "/>
|
||||
<span className="text-xl mt-3 h-0 italic">{t(isOnline ? "pages.version-viewer.mods.loading-mods" : "pages.version-viewer.mods.no-internet")}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -4,9 +4,14 @@ export const defaultConfiguration: {[key in DefaultConfigKey]: any} = {
|
||||
"theme": "os",
|
||||
"language": window.navigator.language.length <= 2 ? `${window.navigator.language}-${window.navigator.language.toLocaleUpperCase()}` : window.navigator.language,
|
||||
"supported_languages": ["en-US", "en-EN", "fr-FR", "es-ES"],
|
||||
"default_mods": ["SongCore", "ScoreSaber", "BeatSaverDownloader", "BeatSaverVoting", "PlaylistManager", "ModelDownloader"]
|
||||
"default_mods": ["SongCore", "WhyIsThereNoLeaderboard", "BeatSaverDownloader", "BeatSaverVoting", "PlaylistManager"],
|
||||
"default-shared-folders": [
|
||||
"Beat Saber_Data\\CustomLevels",
|
||||
"Beat Saber_Data\\CustomWIPLevels",
|
||||
"DLC"
|
||||
]
|
||||
}
|
||||
|
||||
export type DefaultConfigKey = "first-color" | "second-color" | "theme" | "language" | "supported_languages" | "default_mods";
|
||||
export type DefaultConfigKey = "first-color" | "second-color" | "theme" | "language" | "supported_languages" | "default_mods" | "default-shared-folders";
|
||||
|
||||
export type ThemeConfig = "dark" | "light" | "os"
|
||||
export type ThemeConfig = "dark" | "light" | "os"
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
width: calc(100% + 8px);
|
||||
height: calc(100% + 8px);
|
||||
animation: glowing 20s linear infinite;
|
||||
opacity: 0;
|
||||
transition: opacity .2s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes glowing {
|
||||
|
||||
@@ -7,45 +7,99 @@ import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { BSVersionManagerService } from "renderer/services/bs-version-manager.service";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { BsmDropdownButton } from "renderer/components/shared/bsm-dropdown-button.component";
|
||||
import { ProgressBarService } from "renderer/services/progress-bar.service";
|
||||
import { ModalExitCode, ModalService } from "renderer/services/modale.service";
|
||||
import { ImportVersionModal } from "renderer/components/modal/modal-types/import-version-modal.component";
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
import { timer } from "rxjs";
|
||||
|
||||
export function AvailableVersionsList() {
|
||||
|
||||
const bsDownloaderService: BsDownloaderService = BsDownloaderService.getInstance();
|
||||
const versionManagerService: BSVersionManagerService = BSVersionManagerService.getInstance();
|
||||
const bsDownloaderService = BsDownloaderService.getInstance();
|
||||
const versionManagerService = BSVersionManagerService.getInstance();
|
||||
const progressBar = ProgressBarService.getInstance();
|
||||
const modal = ModalService.getInsance();
|
||||
const ipc = IpcService.getInstance();
|
||||
const installer = BsDownloaderService.getInstance();
|
||||
const notification = NotificationService.getInstance();
|
||||
|
||||
const [versionSelected, setVersionSelected] = useState(null as BSVersion);
|
||||
const currentVersionDownloading = useObservable(bsDownloaderService.currentBsVersionDownload$);
|
||||
const [downloading, setDownloading] = useState(false);
|
||||
const t = useTranslation();
|
||||
|
||||
const startDownload = () => {
|
||||
bsDownloaderService.download(versionSelected, versionManagerService.isVersionInstalled(versionSelected));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const versionSelectedSub = bsDownloaderService.selectedBsVersion$.subscribe(version => {
|
||||
setVersionSelected(version);
|
||||
});
|
||||
|
||||
return () => {
|
||||
versionSelectedSub.unsubscribe();
|
||||
const startDownload = () => {
|
||||
setDownloading(() => true)
|
||||
bsDownloaderService.download(versionSelected).finally(() => {
|
||||
setDownloading(() => false);
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const versionSelectedSub = bsDownloaderService.selectedBsVersion$.subscribe(version => {
|
||||
setVersionSelected(version);
|
||||
});
|
||||
|
||||
return () => {
|
||||
versionSelectedSub.unsubscribe();
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
const importVersion = async () => {
|
||||
if(!progressBar.require()){ return; }
|
||||
|
||||
const modalRes = await modal.openModal(ImportVersionModal);
|
||||
|
||||
if(modalRes.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
|
||||
const folderRes = await ipc.sendV2<{canceled: boolean, filePaths: string[]}>("choose-folder").toPromise();
|
||||
|
||||
if(!folderRes || folderRes.canceled || !folderRes.filePaths?.length){ return; }
|
||||
|
||||
notification.notifySuccess({title: "notifications.bs-import-version.success.start-import.title", desc: "notifications.bs-import-version.success.start-import.desc", duration: 6_000});
|
||||
|
||||
progressBar.showFake(.008);
|
||||
|
||||
const toImport = folderRes.filePaths.at(0);
|
||||
|
||||
const imported = await installer.importVersion(toImport);
|
||||
|
||||
if(imported){
|
||||
versionManagerService.askInstalledVersions();
|
||||
notification.notifySuccess({title: "notifications.bs-import-version.success.imported.title", duration: 3_000});
|
||||
progressBar.complete();
|
||||
await timer(400).toPromise();
|
||||
}
|
||||
else{
|
||||
notification.notifyError({title: "notifications.types.error", desc: "notifications.bs-import-version.errors.import-error.desc"})
|
||||
}
|
||||
|
||||
progressBar.hide(true);
|
||||
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<div className="relative h-full w-full flex items-center flex-col pt-2">
|
||||
<Slideshow className="absolute w-full h-full top-0"/>
|
||||
<h1 className="text-gray-100 text-2xl mb-4 z-[1]">{t("pages.available-versions.title")}</h1>
|
||||
<AvailableVersionsSlider/>
|
||||
<Slideshow className="absolute w-full h-full top-0"/>
|
||||
<h1 className="text-gray-100 text-2xl mb-4 z-[1]">{t("pages.available-versions.title")}</h1>
|
||||
|
||||
<AnimatePresence>
|
||||
{ versionSelected && !currentVersionDownloading && (
|
||||
<motion.div initial={{y:"150%"}} animate={{y:"0%"}} exit={{y:"150%"}} className="absolute bottom-5" onClick={startDownload}>
|
||||
<BsmButton text={versionManagerService.isVersionInstalled(versionSelected) ? "misc.verify" : "misc.download"} className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<AvailableVersionsSlider/>
|
||||
|
||||
<AnimatePresence>
|
||||
{ versionSelected && !downloading && (
|
||||
<motion.div initial={{y:"150%"}} animate={{y:"0%"}} exit={{y:"150%"}} className="absolute bottom-5" onClick={startDownload}>
|
||||
<BsmButton text="misc.download" className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
<BsmDropdownButton className="absolute top-5 right-5 h-9 w-9 bg-light-main-color-2 dark:bg-main-color-2 rounded-md" icon="settings" items={[
|
||||
{icon: "sync", text: "pages.available-versions.dropdown.refresh", onClick: () => versionManagerService.askAvailableVersions()},
|
||||
{icon: "download", text: "pages.available-versions.dropdown.import-version", onClick: importVersion}
|
||||
]}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { MapsPlaylistsPanel } from "renderer/components/maps-mangement-components/maps-playlists-panel.component";
|
||||
import { Slideshow } from "renderer/components/slideshow/slideshow.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
|
||||
export function MapsPage() {
|
||||
|
||||
const t = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="w-full h-full flex items-center flex-col pt-2">
|
||||
<Slideshow className="absolute w-full h-full top-0"/>
|
||||
<h1 className="text-gray-100 text-2xl z-[1]">Maps partagées</h1>
|
||||
<h1 className="text-gray-100 text-2xl z-[1]">{t("pages.shared-maps.title")}</h1>
|
||||
<div className="w-full min-h-0 grow p-10 flex flex-col items-center justify-start text-white relative">
|
||||
<MapsPlaylistsPanel/>
|
||||
</div>
|
||||
|
||||
@@ -40,7 +40,6 @@ export function SettingsPage() {
|
||||
const modalService: ModalService = ModalService.getInsance();
|
||||
const downloaderService: BsDownloaderService = BsDownloaderService.getInstance();
|
||||
const progressBarService: ProgressBarService = ProgressBarService.getInstance();
|
||||
const authService: AuthUserService = AuthUserService.getInstance();
|
||||
const notificationService: NotificationService = NotificationService.getInstance();
|
||||
const i18nService: I18nService = I18nService.getInstance();
|
||||
const linkOpener: LinkOpenerService = LinkOpenerService.getInstance();
|
||||
@@ -49,7 +48,6 @@ export function SettingsPage() {
|
||||
const modelsManager = ModelsManagerService.getInstance();
|
||||
|
||||
const {firstColor, secondColor} = useThemeColor();
|
||||
const sessionExist = useObservable(authService.sessionExist$);
|
||||
|
||||
const themeItem: RadioItem[] = [
|
||||
{id: 0, text: "pages.settings.appearance.themes.dark", value: "dark" as ThemeConfig},
|
||||
@@ -110,11 +108,12 @@ export function SettingsPage() {
|
||||
|
||||
modalService.openModal(InstallationFolderModal).then(async res => {
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
const fileChooserRes = await ipcService.send<{canceled: boolean, filePaths: string[]}>("choose-folder");
|
||||
|
||||
if(fileChooserRes.success && !fileChooserRes.data.canceled && fileChooserRes.data.filePaths?.length){
|
||||
const fileChooserRes = await ipcService.sendV2<{canceled: boolean, filePaths: string[]}>("choose-folder").toPromise();
|
||||
|
||||
if(!fileChooserRes.canceled && fileChooserRes.filePaths?.length){
|
||||
progressBarService.showFake(.008);
|
||||
downloaderService.setInstallationFolder(fileChooserRes.data.filePaths[0]).then(res => {
|
||||
downloaderService.setInstallationFolder(fileChooserRes.filePaths[0]).then(res => {
|
||||
setTimeout(() => {
|
||||
progressBarService.complete();
|
||||
setTimeout(() => progressBarService.hide(true), 1000);
|
||||
@@ -132,12 +131,6 @@ export function SettingsPage() {
|
||||
});
|
||||
}
|
||||
|
||||
const deleteSteamSession = () => {
|
||||
if(!sessionExist){ return; }
|
||||
authService.deleteSteamSession();
|
||||
notificationService.notifySuccess({title: "notifications.settings.steam.success.titles.logout", duration: 3000});
|
||||
};
|
||||
|
||||
|
||||
const toogleShowSupporters = () => {
|
||||
setShowSupporters(show => !show);
|
||||
@@ -195,10 +188,6 @@ export function SettingsPage() {
|
||||
<BsmButton className="inline-block grow-0 bg-transparent sticky h-full w-full top-20 right-20 !m-0 rounded-full p-1" onClick={() => nav(-1)} icon="close" withBar={false}/>
|
||||
</div>
|
||||
|
||||
<SettingContainer title="pages.settings.steam.title" description="pages.settings.steam.description">
|
||||
<BsmButton onClick={deleteSteamSession} className="w-fit px-3 py-[2px] text-white rounded-md" withBar={false} text="pages.settings.steam.logout" typeColor="error" disabled={!sessionExist}/>
|
||||
</SettingContainer>
|
||||
|
||||
<SettingContainer title="pages.settings.appearance.title" description="pages.settings.appearance.description">
|
||||
<div className="relative w-full h-8 bg-light-main-color-1 dark:bg-main-color-1 flex justify-center rounded-md py-1">
|
||||
<SettingColorChooser color={firstColor} onChange={setFirstColorSetting}/>
|
||||
@@ -293,8 +282,8 @@ export function SettingsPage() {
|
||||
|
||||
<SettingContainer title="pages.settings.patreon.title" description="pages.settings.patreon.description">
|
||||
<div className="flex gap-2">
|
||||
<BsmButton className="flex w-fit rounded-md h-8 px-2 font-bold py-1 whitespace-nowrap !bg-red-500 !text-white" text="pages.settings.patreon.buttons.support" withBar={false} onClick={openSupportPage}/>
|
||||
<BsmButton className="flex w-fit rounded-md h-8 px-2 font-bold py-1 !text-white" withBar={false} text="pages.settings.patreon.buttons.supporters" color="#6c5ce7" onClick={() => toogleShowSupporters}/>
|
||||
<BsmButton disabled color="#ef4444" className="flex w-fit rounded-md h-8 px-2 font-bold py-1 whitespace-nowrap !text-white" text="pages.settings.patreon.buttons.support" withBar={false} onClick={openSupportPage}/>
|
||||
<BsmButton className="flex w-fit rounded-md h-8 px-2 font-bold py-1 !text-white" withBar={false} text="pages.settings.patreon.buttons.supporters" color="#6c5ce7" onClick={toogleShowSupporters}/>
|
||||
</div>
|
||||
<SettingContainer className="mt-3" description="pages.settings.discord.description">
|
||||
<div className="flex gap-2">
|
||||
|
||||
@@ -15,6 +15,7 @@ import { LaunchSlide } from 'renderer/components/version-viewer/slides/launch/la
|
||||
import { ModsSlide } from 'renderer/components/version-viewer/slides/mods/mods-slide.component';
|
||||
import { UninstallModal } from 'renderer/components/modal/modal-types/uninstall-modal.component';
|
||||
import { MapsPlaylistsPanel } from 'renderer/components/maps-mangement-components/maps-playlists-panel.component';
|
||||
import { ShareFoldersModal } from 'renderer/components/modal/modal-types/share-folders-modal.component';
|
||||
|
||||
export function VersionViewer() {
|
||||
|
||||
@@ -28,7 +29,12 @@ export function VersionViewer() {
|
||||
const navigate = useNavigate();
|
||||
const [currentTabIndex, setCurrentTabIndex] = useState(0);
|
||||
|
||||
const navigateToVersion = (version: BSVersion) => navigate(`/bs-version/${version.BSVersion}`, {state: version});
|
||||
const navigateToVersion = (version?: BSVersion) => {
|
||||
if(!version){
|
||||
return navigate("/available-versions");
|
||||
}
|
||||
navigate(`/bs-version/${version.BSVersion}`, {state: version});
|
||||
}
|
||||
const openFolder = () => ipcService.sendLazy("bs-version.open-folder", {args: state});
|
||||
const verifyFiles = () => bsDownloaderService.download(state, true);
|
||||
|
||||
@@ -36,9 +42,9 @@ export function VersionViewer() {
|
||||
const modalCompleted = await modalService.openModal(UninstallModal, state);
|
||||
if(modalCompleted.exitCode === ModalExitCode.COMPLETED){
|
||||
bsUninstallerService.uninstall(state).then(() => {
|
||||
bsVersionManagerService.askInstalledVersions();
|
||||
const newVersionPage = bsVersionManagerService.getInstalledVersions()[0];
|
||||
navigateToVersion(newVersionPage);
|
||||
bsVersionManagerService.askInstalledVersions().then(versions => {
|
||||
navigateToVersion(versions?.at(0));
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -61,6 +67,10 @@ export function VersionViewer() {
|
||||
setCurrentTabIndex(() => 0);
|
||||
}
|
||||
|
||||
const openShareFolderModal = () => {
|
||||
modalService.openModal(ShareFoldersModal, state);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -82,6 +92,7 @@ export function VersionViewer() {
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.verify-files", icon: "task", onClick: verifyFiles}),
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.edit", icon: "edit", onClick: edit}),
|
||||
(!state.oculus && {text: "pages.version-viewer.dropdown.clone", icon: "copy", onClick: clone}),
|
||||
{text: "pages.version-viewer.dropdown.shared-folders", icon: "link", onClick: openShareFolderModal},
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.uninstall", icon:"trash", onClick: uninstall})
|
||||
]}/>
|
||||
</>
|
||||
|
||||
Vendored
+5
-4
@@ -1,15 +1,16 @@
|
||||
import { Channels, ReplyChannels } from 'main/preload';
|
||||
import { IpcChannel } from "shared/models/ipc/ipc-response.interface";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
electron: {
|
||||
ipcRenderer: {
|
||||
sendMessage(channel: Channels, args: any): void;
|
||||
sendMessage(channel: IpcChannel, args: any): void;
|
||||
on(
|
||||
channel: ReplyChannels,
|
||||
channel: IpcChannel,
|
||||
func: (...args: any) => void
|
||||
): (() => void) | undefined;
|
||||
once(channel: ReplyChannels, func: (...args: any) => void): void;
|
||||
once(channel: IpcChannel, func: (...args: any) => void): void;
|
||||
removeAllListeners(channel: IpcChannel): void;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Observable } from "rxjs";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { Observable, BehaviorSubject } from "rxjs";
|
||||
import { ConfigurationService } from "./configuration.service";
|
||||
|
||||
export class AudioPlayerService{
|
||||
|
||||
@@ -10,18 +10,38 @@ export class AudioPlayerService{
|
||||
return AudioPlayerService.instance;
|
||||
}
|
||||
|
||||
private readonly config: ConfigurationService;
|
||||
|
||||
private readonly player: HTMLAudioElement;
|
||||
|
||||
private readonly _src$: BehaviorSubject<string> = new BehaviorSubject("");
|
||||
private readonly _playing$: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||
private readonly _bpm$: BehaviorSubject<number> = new BehaviorSubject(0);
|
||||
private readonly _volume$: BehaviorSubject<PlayerVolume>;
|
||||
|
||||
private lastVolume: number;
|
||||
|
||||
private constructor(){
|
||||
|
||||
this.config = ConfigurationService.getInstance();
|
||||
|
||||
this._volume$ = new BehaviorSubject(
|
||||
this.config.get<PlayerVolume>("audio-level") || { volume: 0.5, muted: false }
|
||||
);
|
||||
|
||||
this.lastVolume = this._volume$.value.volume;
|
||||
|
||||
this.player = new Audio();
|
||||
|
||||
this.player.onplay = () => this._playing$.next(true);
|
||||
this.player.onpause = () => this._playing$.next(false);
|
||||
this.player.onended = () => this._playing$.next(false);
|
||||
|
||||
this._volume$.subscribe(volume => {
|
||||
this.player.volume = volume.volume;
|
||||
this.player.muted = volume.muted;
|
||||
this.config.set("audio-level", volume);
|
||||
});
|
||||
}
|
||||
|
||||
public play(src: string, bpm = 0): Promise<void>{
|
||||
@@ -41,6 +61,31 @@ export class AudioPlayerService{
|
||||
return this.player.play();
|
||||
}
|
||||
|
||||
public setVolume(volume: number): void{
|
||||
const playerVolume: PlayerVolume = {muted: volume <= 0, volume};
|
||||
this._volume$.next(playerVolume);
|
||||
}
|
||||
|
||||
public setFinalVolume(volume: number): void{
|
||||
if(volume > 0){ this.lastVolume = volume; }
|
||||
const playerVolume: PlayerVolume = {muted: volume <= 0, volume: this.lastVolume};
|
||||
this._volume$.next(playerVolume);
|
||||
}
|
||||
|
||||
public mute(): void{
|
||||
const playerVolume = {...this._volume$.value, muted: true};
|
||||
this._volume$.next(playerVolume);
|
||||
}
|
||||
|
||||
public unmute(): void{
|
||||
const playerVolume = {...this._volume$.value, muted: false};
|
||||
this._volume$.next(playerVolume);
|
||||
}
|
||||
|
||||
public toggleMute(): void{
|
||||
this.muted ? this.unmute() : this.mute();
|
||||
}
|
||||
|
||||
public get src$(): Observable<string>{
|
||||
return this._src$.asObservable();
|
||||
}
|
||||
@@ -50,9 +95,19 @@ export class AudioPlayerService{
|
||||
public get bpm$(): Observable<number>{
|
||||
return this._bpm$.asObservable();
|
||||
}
|
||||
public get volume$(): Observable<PlayerVolume>{
|
||||
return this._volume$.asObservable();
|
||||
}
|
||||
|
||||
public get src(): string{ return this._src$.value; }
|
||||
public get playing(): boolean{ return this._playing$.value; }
|
||||
public get bpm(): number{ return this._bpm$.value; }
|
||||
public get volume(): PlayerVolume{ return this._volume$.value; }
|
||||
public get muted(): boolean{ return this.player.muted; }
|
||||
|
||||
}
|
||||
|
||||
interface PlayerVolume{
|
||||
volume: number;
|
||||
muted: boolean;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DownloadEvent } from 'main/services/bs-installer.service';
|
||||
import { DownloadEvent, DownloadInfo } from 'main/services/bs-installer.service';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { distinctUntilChanged, filter, throttleTime } from 'rxjs/operators';
|
||||
import { IpcResponse } from 'shared/models/ipc';
|
||||
@@ -71,10 +71,15 @@ export class BsDownloaderService{
|
||||
this.ipcService.sendLazy('bs-download.[2FA]', {args: res.data});
|
||||
});
|
||||
|
||||
this.ipcService.watch<BSVersion>("start-download-version").subscribe(res => {
|
||||
this.currentBsVersionDownload$.next(res.data);
|
||||
});
|
||||
|
||||
this.currentBsVersionDownload$.subscribe(version => {
|
||||
if(version){ this.bsVersionManager.setInstalledVersions([...this.bsVersionManager.installedVersions$.value, version]); }
|
||||
else{ this.bsVersionManager.askInstalledVersions(); }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private resetDownload(): void{
|
||||
@@ -91,11 +96,7 @@ export class BsDownloaderService{
|
||||
return this.ipcService.send<boolean>("is-dotnet-6-installed").then(res => res.success && res.data)
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
|
||||
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
|
||||
|
||||
if(isFirstCall && !(await this.isDotNet6Installed())){
|
||||
|
||||
private async showDotNetNotInstalledError(): Promise<void>{
|
||||
const choice = await this.notificationService.notifyError({
|
||||
duration: 11_000,
|
||||
title: "notifications.bs-download.errors.titles.dotnet-required",
|
||||
@@ -106,12 +107,21 @@ export class BsDownloaderService{
|
||||
if(choice === "0"){
|
||||
this.linkOpener.open("https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-6.0.12-windows-x64-installer");
|
||||
}
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
|
||||
|
||||
// TODO : to remake cause we don't need recursion anymore
|
||||
|
||||
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
|
||||
|
||||
if(isFirstCall && !(await this.isDotNet6Installed())){
|
||||
await this.showDotNetNotInstalledError();
|
||||
return {success: false};
|
||||
}
|
||||
|
||||
this.progressBarService.show(this.downloadProgress$);
|
||||
this._isVerification = !!isVerification;
|
||||
this._isVerification = isVerification;
|
||||
|
||||
let promise;
|
||||
if(!this.authService.sessionExist()){
|
||||
@@ -121,14 +131,12 @@ export class BsDownloaderService{
|
||||
return {success: false};
|
||||
}
|
||||
this.authService.setSteamSession(res.data.username, res.data.stay);
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay}});
|
||||
promise = this.ipcService.send<DownloadEvent, DownloadInfo>('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay, isVerification}});
|
||||
}
|
||||
else{
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername()}});
|
||||
promise = this.ipcService.send<DownloadEvent, DownloadInfo>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername(), isVerification}});
|
||||
}
|
||||
|
||||
this.currentBsVersionDownload$.next(bsVersion);
|
||||
|
||||
let res = await promise;
|
||||
|
||||
if(res.data?.type === "[Password]"){
|
||||
@@ -139,21 +147,33 @@ export class BsDownloaderService{
|
||||
this.progressBarService.hide(true);
|
||||
this.resetDownload();
|
||||
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000}); }
|
||||
else if(res.data && isFirstCall){ this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000}); }
|
||||
else if(res.data === "dotnet" && isFirstCall){
|
||||
await this.showDotNetNotInstalledError();
|
||||
return res;
|
||||
}
|
||||
else if(res.data && isFirstCall){
|
||||
this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000});
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public get isDownloading(): boolean{ return !!this.currentBsVersionDownload$.value; }
|
||||
public get isVerification(): boolean{ return this._isVerification; }
|
||||
|
||||
public async getInstallationFolder(): Promise<string>{
|
||||
const res = await this.ipcService.send<string>("bs-download.installation-folder");
|
||||
return res.success ? res.data : "";
|
||||
}
|
||||
|
||||
public get isVerification(): boolean{ return this._isVerification; }
|
||||
|
||||
public setInstallationFolder(path: string): Promise<IpcResponse<string>>{
|
||||
return this.ipcService.send<string>("bs-download.set-installation-folder", {args: path});
|
||||
}
|
||||
|
||||
public async importVersion(pathToImport: string): Promise<boolean>{
|
||||
const res = await this.ipcService.send<void>("bs-download.import-version", {args: pathToImport});
|
||||
return res.success;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ export class BSLauncherService{
|
||||
|
||||
|
||||
|
||||
public launch(version: BSVersion, oculus: boolean, desktop: boolean, debug: boolean): Promise<NotificationResult|string>{
|
||||
const lauchOption: LauchOption = {debug, oculus, desktop, version};
|
||||
public launch(version: BSVersion, oculus: boolean, desktop: boolean, debug: boolean, additionalArgs?: string[]): Promise<NotificationResult|string>{
|
||||
const lauchOption: LauchOption = {debug, oculus, desktop, version, additionalArgs};
|
||||
if(this.launchState$.value){ return this.notificationService.notifyError({title: "notifications.bs-launch.errors.titles.BS_ALREADY_RUNNING"}); }
|
||||
this.launchState$.next(version);
|
||||
return this.ipcService.send<LaunchResult>("bs-launch.launch", {args: lauchOption}).then(res => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ProgressionInterface } from "shared/models/progress-bar";
|
||||
import { IpcService } from "./ipc.service";
|
||||
import { ModalExitCode, ModalService } from "./modale.service";
|
||||
import { NotificationService, NotificationType } from "./notification.service";
|
||||
import { OsDiagnosticService } from "./os-diagnostic.service";
|
||||
import { ProgressBarService } from "./progress-bar.service";
|
||||
|
||||
export class BsModsManagerService {
|
||||
@@ -22,6 +23,7 @@ export class BsModsManagerService {
|
||||
private readonly progressBar: ProgressBarService;
|
||||
private readonly modals: ModalService;
|
||||
private readonly notifications: NotificationService;
|
||||
private readonly os: OsDiagnosticService;
|
||||
|
||||
public readonly isInstalling$: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||
public readonly isUninstalling$: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||
@@ -36,17 +38,27 @@ export class BsModsManagerService {
|
||||
this.progressBar = ProgressBarService.getInstance();
|
||||
this.modals = ModalService.getInsance();
|
||||
this.notifications = NotificationService.getInstance();
|
||||
this.os = OsDiagnosticService.getInstance();
|
||||
}
|
||||
|
||||
public getAvailableMods(version: BSVersion): Promise<Mod[]>{
|
||||
public async getAvailableMods(version: BSVersion): Promise<Mod[]>{
|
||||
return this.ipcService.send<Mod[], BSVersion>("get-available-mods", {args: version}).then(res => res.data);
|
||||
}
|
||||
|
||||
public getInstalledMods(version: BSVersion): Promise<Mod[]>{
|
||||
public async getInstalledMods(version: BSVersion): Promise<Mod[]>{
|
||||
return this.ipcService.send<Mod[], BSVersion>("get-installed-mods", {args: version}).then(res => res.data);
|
||||
}
|
||||
|
||||
public installMods(mods: Mod[], version: BSVersion): Promise<void>{
|
||||
|
||||
if(this.os.isOffline){
|
||||
this.notifications.notifyError({
|
||||
title: "notifications.shared.errors.titles.no-internet",
|
||||
desc: "notifications.shared.errors.msg.no-internet"
|
||||
});
|
||||
return new Promise(res => res());
|
||||
}
|
||||
|
||||
if(!this.progressBar.require()){ return new Promise(res => res()); }
|
||||
|
||||
const progress$: Observable<ProgressionInterface> = this.ipcService.watch<ModInstallProgression>("mod-installed").pipe(map(res => {
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { map, distinctUntilChanged, filter } from "rxjs/operators";
|
||||
import { from } from "rxjs";
|
||||
import { Observable } from "rxjs";
|
||||
import { IpcService } from "./ipc.service";
|
||||
import { ProgressBarService } from "./progress-bar.service";
|
||||
import { NotificationService } from "./notification.service";
|
||||
import { LinkOptions } from "main/services/folder-linker.service";
|
||||
|
||||
export class FolderLinkerService {
|
||||
|
||||
private static instance: FolderLinkerService;
|
||||
|
||||
public static getInstance(): FolderLinkerService {
|
||||
if (!FolderLinkerService.instance) {
|
||||
FolderLinkerService.instance = new FolderLinkerService();
|
||||
}
|
||||
return FolderLinkerService.instance;
|
||||
}
|
||||
|
||||
private readonly ipc: IpcService;
|
||||
private readonly progress: ProgressBarService;
|
||||
private readonly notification: NotificationService;
|
||||
|
||||
private readonly onLinkedListeners = new Map<string, () => void>();
|
||||
private readonly onUnlinkedListeners = new Map<string, () => void>();
|
||||
private readonly onRemovedFromQueueListeners = new Map<string, () => void>();
|
||||
|
||||
private readonly publicOnLinkedListeners = new Set<(folder: string) => void>();
|
||||
private readonly publicOnUnlinkedListeners = new Set<(folder: string) => void>();
|
||||
|
||||
private readonly _currentAction$ = new BehaviorSubject<LinkAction>(null);
|
||||
private readonly _queue$ = new BehaviorSubject<LinkAction[]>([]);
|
||||
|
||||
private constructor() {
|
||||
this.ipc = IpcService.getInstance();
|
||||
this.progress = ProgressBarService.getInstance();
|
||||
this.notification = NotificationService.getInstance();
|
||||
|
||||
this.queue$.pipe(map(queue => !!queue.length), distinctUntilChanged(), filter(haveAction => haveAction)).subscribe(() => {
|
||||
this.startQueue();
|
||||
});
|
||||
}
|
||||
|
||||
private async startQueue(): Promise<void>{
|
||||
|
||||
while(this._queue$.value.at(0)){
|
||||
|
||||
const toDo = this._queue$.value.at(0);
|
||||
|
||||
let progressOpened = false;
|
||||
|
||||
if(!this.progress.isVisible){
|
||||
this.progress.showFake(.01, null, toDo.folder.split("\\").at(-1));
|
||||
progressOpened = true;
|
||||
}
|
||||
|
||||
this._currentAction$.next(toDo);
|
||||
await this.doAction(toDo).toPromise();
|
||||
|
||||
this.specialFolderNotification(toDo);
|
||||
|
||||
if(toDo.type === LinkActionType.Link){
|
||||
this.onLinkedListeners.get(toDo.folder)?.();
|
||||
this.publicOnLinkedListeners.forEach(listener => listener(toDo.folder));
|
||||
this.onLinkedListeners.delete(toDo.folder);
|
||||
}
|
||||
else{
|
||||
this.onUnlinkedListeners.get(toDo.folder)?.();
|
||||
this.publicOnUnlinkedListeners.forEach(listener => listener(toDo.folder));
|
||||
this.onUnlinkedListeners.delete(toDo.folder);
|
||||
}
|
||||
|
||||
const newArr = [...this._queue$.value];
|
||||
newArr.shift();
|
||||
this._queue$.next(newArr);
|
||||
|
||||
if(progressOpened){
|
||||
this.progress.hide(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this._currentAction$.next(null);
|
||||
}
|
||||
|
||||
private specialFolderNotification(action: LinkAction): void{
|
||||
if(action.type === LinkActionType.Link && action.folder.includes("UserData")){
|
||||
this.notification.notifyInfo({
|
||||
title: "notifications.shared-folder.info.userdata-backup-created.title",
|
||||
desc: "notifications.shared-folder.info.userdata-backup-created.msg",
|
||||
duration: 7000
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private doAction(action: LinkAction): Observable<void>{
|
||||
return this.ipc.sendV2<void, {folder: string, options?: LinkOptions}>(action.type === LinkActionType.Link ? "link-folder" : "unlink-folder", { args: { folder: action.folder, options: action.options } });
|
||||
}
|
||||
|
||||
private addFolderToQueue(folder: string, type: LinkActionType, options: LinkOptions){
|
||||
if(this._queue$.value.some(action => action.folder === folder)){ return; }
|
||||
this._queue$.next([...this._queue$.value, {folder, type, options}]);
|
||||
}
|
||||
|
||||
private removeFolderFromQueue(folder: string){
|
||||
const queue = this._queue$.value;
|
||||
const index = queue.findIndex(action => action.folder === folder);
|
||||
if(index === -1){ return; }
|
||||
this.onRemovedFromQueueListeners.get(folder)?.();
|
||||
queue.splice(index, 1);
|
||||
this._queue$.next(queue);
|
||||
}
|
||||
|
||||
private onLinked(folder: string, callback: () => void){ this.onLinkedListeners.set(folder, callback); }
|
||||
private onUnlinked(folder: string, callback: () => void){ this.onUnlinkedListeners.set(folder, callback); }
|
||||
private onRemovedFromQueue(folder: string, callback: () => void){ this.onRemovedFromQueueListeners.set(folder, callback); }
|
||||
|
||||
public isFolderLinked(path: string): Observable<boolean> {
|
||||
return this.ipc.sendV2<boolean>("is-folder-symlink", {args: path});
|
||||
}
|
||||
|
||||
public linkFolders(...folders: string[]): Map<string, Observable<void>> {
|
||||
return new Map(folders.map(folder => [folder, this.linkFolder(folder)]));
|
||||
}
|
||||
|
||||
public linkFolder(folder: string, options: LinkOptions = {}): Observable<void> {
|
||||
options.keepContents ??= true;
|
||||
const promise = new Promise<void>(resolve => {
|
||||
this.onLinked(folder, resolve);
|
||||
this.onRemovedFromQueue(folder, resolve);
|
||||
});
|
||||
|
||||
this.addFolderToQueue(folder, LinkActionType.Link, options);
|
||||
return from(promise);
|
||||
}
|
||||
|
||||
public unlinkFolders(...folders: string[]): Map<string, Observable<void>> {
|
||||
return new Map(folders.map(folder => [folder, this.unlinkFolder(folder)]));
|
||||
}
|
||||
|
||||
public unlinkFolder(folder: string, options: LinkOptions = {}): Observable<void> {
|
||||
options.keepContents ??= true;
|
||||
const promise = new Promise<void>(resolve => {
|
||||
this.onUnlinked(folder, resolve);
|
||||
this.onRemovedFromQueue(folder, resolve);
|
||||
});
|
||||
|
||||
this.addFolderToQueue(folder, LinkActionType.Unlink, options);
|
||||
return from(promise);
|
||||
}
|
||||
|
||||
public cancelFolder(folder: string): void {
|
||||
this.removeFolderFromQueue(folder);
|
||||
}
|
||||
|
||||
public get queue$(): Observable<LinkAction[]> { return this._queue$.asObservable(); }
|
||||
public get currentAction$(): Observable<LinkAction> { return this._currentAction$.asObservable(); }
|
||||
|
||||
public isPending(folder: string): Observable<boolean> {
|
||||
return this.queue$.pipe(map(queue => queue.some(action => action.folder === folder), distinctUntilChanged()));
|
||||
}
|
||||
|
||||
public isProcessing(folder: string): Observable<boolean> {
|
||||
return this.currentAction$.pipe(distinctUntilChanged(), map(action => action?.folder === folder));
|
||||
}
|
||||
|
||||
public onFolderLinked(callback: (folder: string) => void): void { this.publicOnLinkedListeners.add(callback); }
|
||||
public removeOnFolderLinked(callback: (folder: string) => void): void { this.publicOnLinkedListeners.delete(callback); }
|
||||
public onFolderUnlinked(callback: (folder: string) => void): void { this.publicOnUnlinkedListeners.add(callback); }
|
||||
public removeOnFolderUnlinked(callback: (folder: string) => void): void { this.publicOnUnlinkedListeners.delete(callback); }
|
||||
|
||||
}
|
||||
|
||||
export interface LinkAction {
|
||||
folder: string;
|
||||
type: LinkActionType;
|
||||
options?: LinkOptions;
|
||||
}
|
||||
|
||||
export enum LinkActionType {
|
||||
Link,
|
||||
Unlink
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { defaultIfEmpty } from "rxjs/operators";
|
||||
import { Observable } from "rxjs";
|
||||
import { IpcRequest, IpcResponse } from "shared/models/ipc";
|
||||
import { identity } from "rxjs";
|
||||
|
||||
export class IpcService {
|
||||
|
||||
@@ -47,4 +49,30 @@ export class IpcService {
|
||||
return obs;
|
||||
}
|
||||
|
||||
// TODO : Convert all IPCs calls to V2
|
||||
|
||||
public sendV2<T, U = unknown>(channel: string, request?: IpcRequest<U>, defaultValue?: T): Observable<T>{
|
||||
if(!request){ request = {args: null, responceChannel: null}; }
|
||||
if(!request.responceChannel){ request.responceChannel = `${channel}_responce_${crypto.randomUUID()}`; }
|
||||
|
||||
const completeChannel = `${request.responceChannel}_complete`;
|
||||
const errorChannel = `${request.responceChannel}_error`;
|
||||
|
||||
const obs = new Observable<T>(observer => {
|
||||
window.electron.ipcRenderer.on(request.responceChannel, (res: T) => observer.next(res));
|
||||
window.electron.ipcRenderer.on(errorChannel, (err: Error) => observer.error(err));
|
||||
window.electron.ipcRenderer.on(completeChannel, () => observer.complete());
|
||||
}).pipe(defaultValue ? defaultIfEmpty(defaultValue) : identity);
|
||||
|
||||
window.electron.ipcRenderer.once(completeChannel, () => {
|
||||
window.electron.ipcRenderer.removeAllListeners(request.responceChannel);
|
||||
window.electron.ipcRenderer.removeAllListeners(errorChannel);
|
||||
window.electron.ipcRenderer.removeAllListeners(completeChannel);
|
||||
});
|
||||
|
||||
window.electron.ipcRenderer.sendMessage(channel, request);
|
||||
|
||||
return obs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { IpcService } from "./ipc.service";
|
||||
import { OsDiagnosticService } from "./os-diagnostic.service";
|
||||
import equal from "fast-deep-equal/es6";
|
||||
import { CSSProperties } from "react";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
|
||||
export class MapsDownloaderService {
|
||||
|
||||
@@ -28,7 +29,7 @@ export class MapsDownloaderService {
|
||||
private readonly mapsQueue$: BehaviorSubject<MapDownload[]> = new BehaviorSubject([]);
|
||||
private readonly currentDownload$: BehaviorSubject<MapDownload> = new BehaviorSubject(null);
|
||||
private queueMaxLenght = 0;
|
||||
private downloadedListerners: ((map: BsvMapDetail, version: BSVersion) => void)[] = [];
|
||||
private downloadedListerners: ((map: BsmLocalMap, version: BSVersion) => void)[] = [];
|
||||
public readonly progressBarStyle: CSSProperties = {zIndex: 100000, position: "fixed", bottom: "10px", right: 0};
|
||||
|
||||
private constructor(){
|
||||
@@ -50,10 +51,10 @@ export class MapsDownloaderService {
|
||||
while(this.mapsQueue$.value.at(0)){
|
||||
const toDownload = this.mapsQueue$.value.at(0);
|
||||
this.currentDownload$.next(toDownload);
|
||||
const downloaded = await this.downloadMap(toDownload.map, toDownload.version);
|
||||
const downloaded = await this.downloadMap(toDownload.map, toDownload.version).toPromise();
|
||||
|
||||
if(downloaded){
|
||||
this.downloadedListerners.forEach(func => func(toDownload.map, toDownload.version));
|
||||
this.downloadedListerners.forEach(func => func(downloaded, toDownload.version));
|
||||
}
|
||||
|
||||
const newArr = [...this.mapsQueue$.value];
|
||||
@@ -67,14 +68,13 @@ export class MapsDownloaderService {
|
||||
this.progressBar.hide(true);
|
||||
}
|
||||
|
||||
private async downloadMap(map: BsvMapDetail, version: BSVersion): Promise<boolean>{
|
||||
if(this.os.isOffline){ return false }
|
||||
const res = await this.ipc.send<void, {map: BsvMapDetail, version: BSVersion}>("download-map", {args: {map, version}});
|
||||
return res.success;
|
||||
private downloadMap(map: BsvMapDetail, version: BSVersion): Observable<BsmLocalMap>{
|
||||
if(this.os.isOffline){ return null }
|
||||
return this.ipc.sendV2<BsmLocalMap, {map: BsvMapDetail, version: BSVersion}>("download-map", {args: {map, version}});
|
||||
}
|
||||
|
||||
public async openDownloadMapModal(version?: BSVersion): Promise<ModalResponse<void>>{
|
||||
const res = await this.modals.openModal(DownloadMapsModal, version);
|
||||
public async openDownloadMapModal(version?: BSVersion, ownedMaps: BsmLocalMap[] = []): Promise<ModalResponse<void>>{
|
||||
const res = await this.modals.openModal(DownloadMapsModal, {version, ownedMaps});
|
||||
this.progressBar.setStyle(null);
|
||||
return res;
|
||||
}
|
||||
@@ -109,11 +109,11 @@ export class MapsDownloaderService {
|
||||
return this.mapsQueue$.asObservable();
|
||||
}
|
||||
|
||||
public addOnMapDownloadedListener(func: (map: BsvMapDetail, version: BSVersion) => void){
|
||||
public addOnMapDownloadedListener(func: (map: BsmLocalMap, version: BSVersion) => void){
|
||||
this.downloadedListerners.push(func);
|
||||
}
|
||||
|
||||
public removeOnMapDownloadedListene(func: (map: BsvMapDetail, version: BSVersion) => void){
|
||||
public removeOnMapDownloadedListener(func: (map: BsmLocalMap, version: BSVersion) => void){
|
||||
const funcIndex = this.downloadedListerners.indexOf(func);
|
||||
if(funcIndex < 0){ return; }
|
||||
this.downloadedListerners.splice(funcIndex, 1);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { LinkMapsModal } from "renderer/components/modal/modal-types/link-maps-modal.component";
|
||||
import { UnlinkMapsModal } from "renderer/components/modal/modal-types/unlink-maps-modal.component";
|
||||
import { Subject, Observable } from "rxjs";
|
||||
import { Subject, Observable, of } from "rxjs";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { BeatSaverService } from "./thrird-partys/beat-saver.service";
|
||||
import { BsmLocalMapsProgress, BsmLocalMap, DeleteMapsProgress } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { IpcService } from "./ipc.service";
|
||||
import { ModalExitCode, ModalService } from "./modale.service";
|
||||
import { DeleteMapsModal } from "renderer/components/modal/modal-types/delete-maps-modal.component";
|
||||
@@ -11,6 +10,10 @@ import { ProgressBarService } from "./progress-bar.service";
|
||||
import { OpenSaveDialogOption } from "shared/models/ipc";
|
||||
import { NotificationService } from "./notification.service";
|
||||
import { ConfigurationService } from "./configuration.service";
|
||||
import { ArchiveProgress } from "shared/models/archive.interface";
|
||||
import { map, last, catchError, distinctUntilChanged, mergeMap } from "rxjs/operators";
|
||||
import { ProgressionInterface } from "shared/models/progress-bar";
|
||||
import { FolderLinkerService } from "./folder-linker.service";
|
||||
|
||||
export class MapsManagerService {
|
||||
|
||||
@@ -24,50 +27,35 @@ export class MapsManagerService {
|
||||
public static readonly REMEMBER_CHOICE_DELETE_MAP_KEY = "not-confirm-delete-map"
|
||||
|
||||
private readonly ipcService: IpcService;
|
||||
private readonly bsaver: BeatSaverService;
|
||||
private readonly modal: ModalService;
|
||||
private readonly progressBar: ProgressBarService;
|
||||
private readonly notifications: NotificationService;
|
||||
private readonly config: ConfigurationService;
|
||||
private readonly linker: FolderLinkerService;
|
||||
|
||||
private readonly lastLinkedVersion$: Subject<BSVersion> = new Subject();
|
||||
private readonly lastUnlinkedVersion$: Subject<BSVersion> = new Subject();
|
||||
|
||||
private constructor(){
|
||||
this.ipcService = IpcService.getInstance();
|
||||
this.bsaver = BeatSaverService.getInstance();
|
||||
this.modal = ModalService.getInsance();
|
||||
this.progressBar = ProgressBarService.getInstance();
|
||||
this.notifications = NotificationService.getInstance();
|
||||
this.config = ConfigurationService.getInstance();
|
||||
this.linker = FolderLinkerService.getInstance();
|
||||
}
|
||||
|
||||
public getMaps(version?: BSVersion, withDetails = true): Observable<BsmLocalMap[]>{
|
||||
return new Observable(obs => {
|
||||
this.ipcService.send<BsmLocalMap[], BSVersion>("get-version-maps", {args: version}).then(res => {
|
||||
if(!res.success){ return obs.complete();}
|
||||
|
||||
obs.next(res.data);
|
||||
|
||||
if(!withDetails){ return obs.complete(); }
|
||||
|
||||
this.bsaver.getMapDetailsFromHashs(res.data.map(localMap => localMap.hash)).then(mapsDetails => {
|
||||
mapsDetails.forEach(details => {
|
||||
const corespondingMap = res.data.find(localMap => localMap.hash === details.versions.find(details => details?.hash === localMap.hash)?.hash);
|
||||
if(!corespondingMap){ return; }
|
||||
res.data.find(localMap => localMap.hash === details.versions.find(details => details?.hash === localMap.hash)?.hash).bsaverInfo = details
|
||||
});
|
||||
obs.next(res.data);
|
||||
})
|
||||
});
|
||||
});
|
||||
private async getVersionMapsPath(version: BSVersion): Promise<string>{
|
||||
return this.ipcService.sendV2<string>("get-version-maps-path", {args: version}).toPromise();
|
||||
}
|
||||
|
||||
public versionHaveMapsLinked(version: BSVersion): Promise<boolean>{
|
||||
return this.ipcService.send<boolean, BSVersion>("verion-have-maps-linked", {args: version}).then(res => {
|
||||
if(!res.success){ throw "error"; }
|
||||
return res.data;
|
||||
})
|
||||
public getMaps(version?: BSVersion): Observable<BsmLocalMapsProgress>{
|
||||
return this.ipcService.sendV2<BsmLocalMapsProgress>("load-version-maps", {args: version}, {loaded: 0, total: 0, maps: []});
|
||||
}
|
||||
|
||||
public async versionHaveMapsLinked(version: BSVersion): Promise<boolean>{
|
||||
const versionMapsPath = await this.getVersionMapsPath(version);
|
||||
return this.linker.isFolderLinked(versionMapsPath).toPromise();
|
||||
}
|
||||
|
||||
public async linkVersion(version: BSVersion): Promise<void>{
|
||||
@@ -76,21 +64,9 @@ export class MapsManagerService {
|
||||
|
||||
if(modalRes.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
|
||||
const showProgressBar = this.progressBar.require();
|
||||
const versionMapsPath = await this.getVersionMapsPath(version);
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.showFake(.01);
|
||||
}
|
||||
|
||||
const res = await this.ipcService.send<void, {version: BSVersion, keepMaps: boolean}>("link-version-maps", {args: {version, keepMaps: !!modalRes.data}});
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.hide(true);
|
||||
}
|
||||
|
||||
if(res.success){
|
||||
this.lastLinkedVersion$.next(version);
|
||||
}
|
||||
return this.linker.linkFolder(versionMapsPath, {keepContents: !!modalRes.data}).toPromise();
|
||||
}
|
||||
|
||||
public async unlinkVersion(version: BSVersion): Promise<void>{
|
||||
@@ -99,21 +75,9 @@ export class MapsManagerService {
|
||||
|
||||
if(modalRes.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
|
||||
const showProgressBar = this.progressBar.require();
|
||||
const versionMapsPath = await this.getVersionMapsPath(version);
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.showFake(.01);
|
||||
}
|
||||
|
||||
const res = await this.ipcService.send<void, {version: BSVersion, keepMaps: boolean}>("unlink-version-maps", {args: {version, keepMaps: !!modalRes.data}});
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.hide(true);
|
||||
}
|
||||
|
||||
if(res.success){
|
||||
this.lastUnlinkedVersion$.next(version);
|
||||
}
|
||||
return this.linker.unlinkFolder(versionMapsPath, {keepContents: !!modalRes.data}).toPromise();
|
||||
}
|
||||
|
||||
public async deleteMaps(maps: BsmLocalMap[], version?: BSVersion): Promise<boolean>{
|
||||
@@ -129,17 +93,13 @@ export class MapsManagerService {
|
||||
|
||||
const showProgressBar = this.progressBar.require();
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.showFake(.008);
|
||||
}
|
||||
const progress$ = this.ipcService.sendV2<DeleteMapsProgress>("delete-maps", {args: maps}).pipe(map(progress => (progress.deleted / progress.total) * 100));
|
||||
|
||||
const res = await this.ipcService.send<void, {version: BSVersion, maps: BsmLocalMap[]}>("delete-maps", {args: {version, maps}});
|
||||
showProgressBar && this.progressBar.show(progress$, true);
|
||||
|
||||
if(showProgressBar){
|
||||
this.progressBar.hide(true);
|
||||
}
|
||||
progress$.toPromise().finally(() => this.progressBar.hide(true));
|
||||
|
||||
return res.success;
|
||||
return progress$.pipe(last(), map(() => true), catchError(() => of(false))).toPromise().catch(() => false);
|
||||
}
|
||||
|
||||
public async exportMaps(version: BSVersion, maps?: BsmLocalMap[]): Promise<void>{
|
||||
@@ -152,18 +112,22 @@ export class MapsManagerService {
|
||||
|
||||
if(!resFile.success){ return; }
|
||||
|
||||
this.progressBar.showFake(.008);
|
||||
|
||||
const resExport = await this.ipcService.send<string, {version: BSVersion, maps: BsmLocalMap[], outPath: string}>("export-maps", {args: {version, maps, outPath: resFile.data}});
|
||||
if(!resExport.success && resExport.error.title){
|
||||
const {title, msg} = resExport.error;
|
||||
this.notifications.notifyError({title, desc: msg});
|
||||
}
|
||||
else {
|
||||
const exportProgress$: Observable<ProgressionInterface> = await this.ipcService.sendV2<ArchiveProgress, {version: BSVersion, maps: BsmLocalMap[], outPath: string}>("export-maps", {args: {version, maps, outPath: resFile.data}}).pipe(
|
||||
map(p => {
|
||||
return { progression: (p.prossesedFiles / p.totalFiles) * 100, label: `${p.prossesedFiles} / ${p.totalFiles}` } as ProgressionInterface
|
||||
})
|
||||
);
|
||||
|
||||
this.progressBar.show(exportProgress$, true);
|
||||
|
||||
await exportProgress$.toPromise().catch(e => {
|
||||
this.notifications.notifyError({title: "notifications.types.error", desc: e.message});
|
||||
}).then(() => {
|
||||
this.notifications.notifySuccess({title: "Export terminé 🎉", duration: 3000});
|
||||
}
|
||||
this.progressBar.complete();
|
||||
this.progressBar.hide(true);
|
||||
this.progressBar.complete();
|
||||
this.progressBar.hide(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public async isDeepLinksEnabled(): Promise<boolean>{
|
||||
@@ -189,4 +153,11 @@ export class MapsManagerService {
|
||||
return this.lastUnlinkedVersion$.asObservable();
|
||||
}
|
||||
|
||||
public $mapsLinkingPending(version: BSVersion): Observable<boolean>{
|
||||
return this.linker.queue$.pipe(mergeMap(async queue => {
|
||||
const versionMapsPath = await this.getVersionMapsPath(version);
|
||||
return queue.some(q => q.folder.includes(versionMapsPath));
|
||||
}), distinctUntilChanged());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export class ModalService{
|
||||
|
||||
}
|
||||
|
||||
export type ModalComponent<T = unknown, K = any> = ({resolver, data}: {resolver : (x: ModalResponse<T>) => void, data?: K}) => JSX.Element;
|
||||
export type ModalComponent<Return = unknown, Receive = any> = ({resolver, data}: {resolver : (x: ModalResponse<Return>) => void, data?: Receive}) => JSX.Element;
|
||||
|
||||
export const enum ModalExitCode {
|
||||
NO_CHOICE = -1,
|
||||
|
||||
@@ -53,6 +53,11 @@ export class NotificationService{
|
||||
return this.notify(notification);
|
||||
}
|
||||
|
||||
public notifyInfo(notification: Notification): Promise<NotificationResult|string>{
|
||||
notification.type = NotificationType.INFO;
|
||||
return this.notify(notification);
|
||||
}
|
||||
|
||||
public notifySystem(options: SystemNotificationOptions){
|
||||
this.ipc.sendLazy<SystemNotificationOptions>("notify-system", {args: options});
|
||||
}
|
||||
@@ -71,6 +76,7 @@ export enum NotificationType {
|
||||
SUCCESS = 0,
|
||||
WARNING = 1,
|
||||
ERROR = 2,
|
||||
INFO = 3,
|
||||
}
|
||||
|
||||
export interface NotificationAction {
|
||||
|
||||
@@ -9,7 +9,7 @@ export class OsDiagnosticService {
|
||||
return OsDiagnosticService.instance;
|
||||
}
|
||||
|
||||
private _isOnline$ = new BehaviorSubject(true);
|
||||
private _isOnline$ = new BehaviorSubject(navigator.onLine);
|
||||
|
||||
private constructor(){
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user