Compare commits

...

70 Commits

Author SHA1 Message Date
SpikeHD
4c9dad49c4 version bump 2022-07-09 23:14:48 -07:00
SpikeHD
960fcae647 Merge branch 'main' of https://github.com/Grasscutters/Cultivation 2022-07-09 22:52:04 -07:00
SpikeHD
4172ee9106 move copy_file to file_helpers 2022-07-09 22:50:41 -07:00
SpikeHD
8566e7f35e remove legacy bg folder creation 2022-07-09 22:49:37 -07:00
SpikeHD
0b2296f918 Merge pull request #20 from Seeker14491/cleanup
Update backend deps & Fix clippy lints
2022-07-09 10:35:03 -07:00
Brian Bowman
6f997a38d3 Remove unneeded thread spawn
As of `open` v3.0.0, this function never blocks, so we don't need to spawn a thread.
2022-07-09 07:11:31 -05:00
Brian Bowman
cd128741b4 Update dependencies 2022-07-09 07:11:31 -05:00
Brian Bowman
174a7b5163 Fix clippy lints 2022-07-09 07:11:31 -05:00
Brian Bowman
e75474fde7 Replace lazy_static with once_cell
`once_cell` is a simpler macroless alternative that will be added to the standard library.
2022-07-09 07:05:38 -05:00
Brian Bowman
c3119ce7a7 Remove unused runas dependency 2022-07-09 05:54:04 -05:00
SpikeHD
6c4b546de2 Update README.md 2022-07-09 01:57:41 -07:00
SpikeHD
30388eb6a9 Update README.md 2022-07-09 01:57:08 -07:00
SpikeHD
afdbc5ad80 Merge pull request #16 from phuchptty/main
add vietnamese language file
2022-07-06 09:26:00 -07:00
phuchptty
1c0edd2bcd feat: add vietnamese language file 2022-07-06 22:38:59 +07:00
SpikeHD
8ac4d063a4 Merge pull request #14 from Seeker14491/unix-fix
Fix build errors on Unix
2022-07-05 21:50:33 -07:00
Brian Bowman
bb9a044e05 Fix reading config on Unix 2022-07-05 22:58:56 -05:00
Brian Bowman
4f63e55a28 Fix build errors on Unix 2022-07-05 19:39:48 -05:00
SpikeHD
a3e1898d82 Update README.md 2022-07-05 12:26:14 -07:00
SpikeHD
5bca75629c Merge pull request #15 from TukanDev/main
Documentation for classes used for react components under /common and some small fixes
2022-07-05 11:49:53 -07:00
TukanDev
0c1fb3e25e remove hover and disabled state docs for bigbutton class 2022-07-05 20:48:34 +02:00
SpikeHD
9558fb0eaf Update THEMES.md 2022-07-05 11:46:18 -07:00
TukanDev
f0d08f5e67 Fix index.json example not having customBackgroundFile key 2022-07-05 20:31:14 +02:00
TukanDev
2af33ccc33 Added documentation for react components under /common and fix for some leftover element id's on commonly used components that I missed. 2022-07-05 20:23:20 +02:00
SpikeHD
8f6ae91a8a Merge pull request #13 from timius100/main
Added latvian language file
2022-07-04 18:54:51 -07:00
SpikeHD
49e77366d1 Merge pull request #12 from yann48gmx/main
French language file
2022-07-04 18:54:10 -07:00
Timur
a826c8e835 Added latvian language file 2022-07-05 01:47:21 +03:00
yann48gmx
bdc7c28ba7 Update fr.json 2022-07-04 22:07:26 +02:00
yann48gmx
1fb8a49a20 French language file 2022-07-04 22:06:29 +02:00
SpikeHD
c57a4ac56d Merge pull request #11 from timius100/main
Added russian language file
2022-07-04 09:33:39 -07:00
Timur
b72dfb8802 Added russian language file 2022-07-04 15:28:31 +03:00
SpikeHD
b00325ca68 Merge pull request #9 from Seeker14491/fix-news
Fix fetching commits from API
2022-07-03 19:23:43 -07:00
SpikeHD
8eaab56787 Merge pull request #10 from TukanDev/main
Fix reusable react components duplicate id...
2022-07-03 19:21:38 -07:00
TukanDev
9ea92a23ee Fix reusable react components duplicate id... dumbass 2022-07-04 04:14:35 +02:00
Brian Bowman
5d2f803f3c Fix fetching commits from API 2022-07-03 17:36:45 -05:00
SpikeHD
29716c43b6 Merge pull request #8 from TukanDev/main
Add element id's and their documentation
2022-07-03 15:15:45 -07:00
SpikeHD
2590082041 reword 2022-07-03 15:15:20 -07:00
SpikeHD
0ec9ef92ee cleanup 2022-07-03 15:10:49 -07:00
TukanDev
98f530eb0c Add element id's and their documentation 2022-07-03 23:46:02 +02:00
SpikeHD
d9416b4fb6 Merge pull request #6 from DasIschBims/main
Added german language file
2022-07-03 11:48:07 -07:00
DasIschBims
73a7d08b8e Added german language file 2022-07-03 17:01:25 +02:00
SpikeHD
3931fa25d6 Update THEMES.md 2022-07-02 21:12:54 -07:00
SpikeHD
84c3645ae2 theming documentation 2022-07-02 21:06:14 -07:00
SpikeHD
54b20a93ef Merge pull request #5 from Kimi898246/patch-2
minor edits cause i fucked up again
2022-07-02 20:48:40 -07:00
Kimi
20130061ab minor edits cause i fucked up again
oops
2022-07-03 11:40:56 +08:00
SpikeHD
e2393d7900 Merge pull request #4 from Kimi898246/patch-1
Traditional Chinese | Translation Patches
2022-07-02 20:30:05 -07:00
Kimi
a42718f6c5 Traditional Chinese | Translation Patches 2022-07-03 11:29:29 +08:00
SpikeHD
de81f9bcac version bump 2022-07-02 20:10:04 -07:00
SpikeHD
3aeacad28c fix theme backgrounds 2022-07-02 20:03:05 -07:00
SpikeHD
27cbd4705b set new icon 2022-07-02 15:01:46 -07:00
SpikeHD
24c578b411 fix button text not updating 2022-07-02 14:46:55 -07:00
SpikeHD
a6a33a9886 button styling 2022-07-02 14:24:18 -07:00
SpikeHD
17ea745e23 toggle encryption in options 2022-07-02 14:16:20 -07:00
SpikeHD
98a948d377 default updater to off 2022-07-02 13:29:13 -07:00
KingRainbow44
eaa3a4299b Add instruction to turn off useInRouting 2022-07-02 15:57:09 -04:00
KingRainbow44
bbf4c7033a Add common issue with the launcher not starting 2022-07-02 15:40:51 -04:00
Magix
cbd05d2c42 Fix startup crash & file loading
Merge pull request #3 from Seeker14491/fix-windows
2022-07-02 11:31:07 -04:00
Brian Bowman
f6b80e1fac Fix Windows path issues 2022-07-02 02:12:12 -05:00
KingRainbow44
241b2b07bd Merge remote-tracking branch 'origin/main' 2022-07-01 16:26:22 -04:00
KingRainbow44
ec2f0f3ff8 Add debug mode as a config setting 2022-07-01 16:26:06 -04:00
KingRainbow44
578d17764c Change logic for command invoking 2022-07-01 16:25:52 -04:00
KingRainbow44
63f2a3a573 Add allowed http URLs 2022-07-01 16:25:38 -04:00
KingRainbow44
b034c73c72 Change to api.grasscutter.io 2022-07-01 16:25:18 -04:00
KingRainbow44
3b99b9137a Add duct as a dependency 2022-07-01 16:24:02 -04:00
Magix
39376aed8c Add the 'zh-CN'
Add Simplified Chinese translation
2022-06-30 12:41:50 -04:00
Tesutarin
4e1053761f Update chs.json 2022-06-30 16:47:55 +08:00
Tesutarin
8f648c16da Add Simplified Chinese translation 2022-06-30 10:56:25 +08:00
SpikeHD
68fb7dd36a Merge pull request #1 from Kimi898246/patch-1
Traditional Chinese | Translation JSON
2022-06-29 18:07:06 -07:00
Kimi
1327c077a7 Update cht.json 2022-06-30 05:37:59 +08:00
Kimi
12305c0dc9 Update cht.json 2022-06-30 04:48:24 +08:00
Kimi
15d53273d0 Traditional Chinese | Translation JSON
I think the title is self-explanatory enough..
2022-06-30 04:32:13 +08:00
56 changed files with 7943 additions and 7196 deletions

View File

@@ -3,6 +3,38 @@
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="HtmlUnknownBooleanAttribute" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="HttpUrlsUsage" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredUrls">
<list>
<option value="http://localhost" />
<option value="http://127.0.0.1" />
<option value="http://0.0.0.0" />
<option value="http://www.w3.org/" />
<option value="http://json-schema.org/draft" />
<option value="http://java.sun.com/" />
<option value="http://xmlns.jcp.org/" />
<option value="http://javafx.com/javafx/" />
<option value="http://javafx.com/fxml" />
<option value="http://maven.apache.org/xsd/" />
<option value="http://maven.apache.org/POM/" />
<option value="http://www.springframework.org/schema/" />
<option value="http://www.springframework.org/tags" />
<option value="http://www.springframework.org/security/tags" />
<option value="http://www.thymeleaf.org" />
<option value="http://www.jboss.org/j2ee/schema/" />
<option value="http://www.jboss.com/xml/ns/" />
<option value="http://www.ibm.com/webservices/xsd" />
<option value="http://activemq.apache.org/schema/" />
<option value="http://schema.cloudfoundry.org/spring/" />
<option value="http://schemas.xmlsoap.org/" />
<option value="http://cxf.apache.org/schemas/" />
<option value="http://primefaces.org/ui" />
<option value="http://tiles.apache.org/" />
<option value="http://api.grasscutter.io" />
<option value="http://api.grasscutters.xyz" />
</list>
</option>
</inspection_tool>
<inspection_tool class="JSIgnoredPromiseFromCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@@ -8,9 +8,9 @@ Consider Cultivation to be the bleeding-edge version of GrassClipper.
During this open-beta testing period, **helpful issues are appreciated**, while unhelpful ones will be closed.
## Fair Warning
Cultivation is **VERY MUCH IN BETA** and a majority of features do not work.\
There are **no official releases of Cultivation**. You are **required** to build the application from **scratch**.\
Please do **NOT install, download, or use pre-compiled versions of Cultivation**. Only use releases from this GitHub repository.
Cultivation is **VERY MUCH IN BETA**.
There are **no official releases of Cultivation**. You are **required** to build the application from **scratch** unless you want to deal with the alpha state of the current builds.
Please do **NOT install, download, or use pre-compiled versions of Cultivation found elsewhere**. Only use releases from this GitHub repository.
# Cultivation
A game launcher designed to easily proxy traffic from anime game to private servers.
@@ -21,6 +21,7 @@ A game launcher designed to easily proxy traffic from anime game to private serv
* [Setup](#setup)
* [Building](#building)
* [Troubleshooting](#troubleshooting)
* [Theming](#theming)
# Download
[Find release builds here!](https://github.com/Grasscutters/Cultivation/releases)
@@ -30,6 +31,7 @@ Once downloaded, extract somewhere and open as administrator.
# Developer Quickstart
### Setup
* Install [NodeJS >12](https://nodejs.org/en/)
* Install [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) & [Rust compiler](https://www.rust-lang.org/tools/install)
* `npm install` or `yarn install`
* `npm run start:dev` or `yarn start:dev`
@@ -48,6 +50,10 @@ Add `--release` or `--debug` depending on what release you are creating. This de
# Troubleshooting
TODO. Collect common issues before updating.
# Theming
A full theming reference can be found [here!](/THEMES.md)
# Screenshots
![image](https://user-images.githubusercontent.com/25207995/173211603-e5e85df7-7fd3-430b-9246-749ebbc1e483.png)
![image](https://user-images.githubusercontent.com/25207995/173211543-b7e88943-cfd2-418b-ac48-7f856868129b.png)
@@ -58,4 +64,4 @@ TODO. Collect common issues before updating.
## Credits
* [SpikeHD](https://github.com/SpikeHD): For originally creating **GrassClipper** and creating the amazing UI of Cultivation.
* [KingRainbow44](https://github.com/KingRainbow44): For building a proxy daemon from scratch and integrating it with Cultivation.
* [Tauri](https://tauri.app): For providing an amazing, efficient, and simple desktop application framework/library.
* [Tauri](https://tauri.app): For providing an amazing, efficient, and simple desktop application framework/library.

106
THEMES.md Normal file
View File

@@ -0,0 +1,106 @@
# Downloading/Installing Themes
1. Download your favorite theme! (You can find some in the `#themes` channel on Discord)
2. Place the unzipped theme folder inside of `%appdata%/cultivation/themes` (The path should look something like this: `cultivation/themes/theme_name/index.json`)
4. Enable within Cultivation!
# Creating your own theme
Themes support entirely custom JS and CSS, enabling you to potentially change every single thing about Cultivation with relative ease.
You can refer to the example theme [found here.](https://cdn.discordapp.com/attachments/992943872479084614/992993575652565002/Example.zip)
You will need CSS and JS experience if you want to do anything cool.
## Creating index.json
`index.json` is where you tell Cultivation which files and images to include. It supports the following properties:
| Property | Description |
| :--- | :--- |
| `name` | The name of the theme. |
| `version` | Not shown anywhere, the version of the theme. |
| `description` | Not shown anywhere, the description of the theme. |
| `includes` | The files and folders to include. |
| `includes.css` | Array of CSS files to include. Example: `css: ["index.css"]` |
| `includes.js` | Array of JS files to includes. Example `js: ["index.js"]` |
| `customBackgroundURL` | A custom image URL to set as the background. Backgrounds that users set in their config supercede this. Example: `"https://website.com/image.png"` |
| `customBackgroundFile` | Path to a custom background image file. Backgrounds that users set in their config supercede this. Example: `"/image.png"` |
A full, complete `index.json` will look something like this:
```json
{
"name": "Example",
"version": "1.0.0",
"description": "This is an example theme. Made by SpikeHD.",
"includes": {
"css": ["/index.css"],
"js": ["/index.js"]
},
"customBackgroundURL": "https://website.com/image.png",
"customBackgroundFile": "/image.png"
}
```
**Important Note:**
All paths are relative to the theme folder. This means you only need to do `"/index.css"` to include `index.css` from the same folder `index.json` is located.
## Writing your CSS
You are welcome to use the DevTools to debug your theme, or view what properties an element has already, etc.
Below are some small examples of what you can do:
```css
/* Change the font */
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}
```
```css
/* Remove the news section */
.NewsSection {
display: none;
}
```
```css
/* Change the right bar width */
.RightBar {
width: 300px;
}
```
## How can I change XYZ element?
Every element is documented and describe [here](/docs/elementIds.md). Every\* single DOM element is assigned an ID to allow for easy and hyper-specific editing.
## Writing your JS
There are no limitations to what you can do with JS. It is safe, as it is sandboxed within the webpage, so there is no possibility of it being able to do anything more than what any regular webpage can do.
Below are some examples of what you can do:
```js
/* Change the version number every 500ms */
setInterval(() => {
document.getElementById("version").innerHTML = "v" + Math.floor(Math.random() * 100);
}, 500);
```
```js
/* Load a custom font */
const head = document.head
const link = document.createElement("link")
link.href = "https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap"
link.rel = "stylesheet"
link.type = "text/css"
head.appendChild(link)
```
```js
/* Create a new button that does nothing */
const newButton = document.createElement("button");
newButton.innerHTML = "New Button";
document.body.appendChild(newButton);
```

133
docs/elementIds.md Normal file
View File

@@ -0,0 +1,133 @@
# Documentation of Element ID's and Classes for custom theming
## IDs
This does not include commonly used components (buttons, divider lines, commit author and message, etc...) for accessing and modifying those elements, please check `Classes` section bellow.
| #ID | Description |
|----------------------------------------|-----------------------------------------------------------------|
| `#miniDialogContainer` | Main container of MiniDialog |
| `#miniDialogContainerTop` | Affects only top section of MiniDialog |
| `#miniDialogButtonClose` | Close button (SVG) of MiniDialog |
| `#miniDialogContent` | MiniDialog content |
| `#rightBarContainer` | Main container of RightBar |
| `#rightBarContent` | RightBar content |
| `#rightBarButtonDiscord` | Discord button on the RightBar |
| `#rightBarButtonGithub` | Github button on the RightBar |
| `#playButton` | Main container for whole launch buttons section |
| `#serverControls` | Container of "play on grasscutter" checkbox |
| `#enableGC` | "play on grasscutter" checkbox |
| `#ip` | Server ip input if play on grasscutter is enabled |
| `#port` | Server port input if play on grasscutter is enabled |
| `#httpsEnable` | "Enable https" checkbox if play on grasscutter is enabled |
| `#officialPlay` | Launch button |
| `#serverLaunch` | Launch server button |
| `#serverlaunchIcon` | Icon (SVG) of server launch button |
| `#serverConfigContainer` | Main container of server configuration section |
| `#serverLaunchContainer` | Main container of launch buttons (includes launch server) |
| `#topBarContainer` | Main container of launcher TopBar (minimize, exit, settings...) |
| `#title` | Title of the TopBar |
| `#version` | Version of the launcher in TopBar |
| `#topBarButtonContainer` | Container of launcher TopBar buttons only |
| `#closeBtn` | Exit launcher button |
| `#minBtn` | Minimize launcher button |
| `#settingsBtn` | Settings button |
| `#downloadsBtn` | Downloads button (grasscutter resources, grasscutter...) |
| `#newsContainer` | Main container of the news section |
| `#newsTabsContainer` | Container for news tabs |
| `#commits` | News tabs container commits button |
| `#latest_version` | News tabs for latest version button |
| `#newsContent` | Content section of news container |
| `#newsCommitsTable` | Commits table of news section |
| `#downloadMenuContainerGCStable` | Grasscutter stable update container |
| `#downloadMenuLabelGCStable` | Label for stable update button |
| `#downloadMenuButtonGCStable` | Button container for stable update button |
| `#grasscutterStableBtn` | "Update grasscutter stable" button |
| `#downloadMenuContainerGCDev` | Grasscutter development update container |
| `#downloadMenuLabelGCDev` | Label for latest update button |
| `#downloadMenuButtonGCDev` | Button container for latest update button |
| `grasscutterLatestBtn` | "Update grasscutter latest" button |
| `#downloadMenuContainerGCStableData` | Grasscutter stable data update container |
| `#downloadMenuLabelGCStableData` | Label for stable data update |
| `#downloadMenuButtonGCStableData` | Button container for stable data update button |
| `#grasscutterStableRepo` | "Update grasscutter stable data" button |
| `#downloadMenuContainerGCDevData` | Grasscutter latest data update container |
| `#downloadMenuLabelGCDevData` | Label for latest data update |
| `#downloadMenuButtonGCDevData` | Button container for latest data update button |
| `#grasscutterDevRepo` | "Update grasscutter latest data" button |
| `#downloadMenuContainerResources` | Container for grasscutter resources download |
| `#downloadMenuLabelResources` | label for resources download |
| `#downloadMenuButtonResources` | Button container for resources download button |
| `#resourcesBtn` | "Download grasscutter resources" button |
| `#menuContainer` | Generic Popup modal like menu container |
| `#menuContainerTop` | Top section of menu container |
| `#menuHeading` | Menu title |
| `#menuButtonCloseContainer` | Container for menu close button |
| `#menuButtonCloseIcon` | Menu close icon (SVG) |
| `#menuContent` | Content section of the menu |
| `#menuOptionsContainerGameExec` | Container for game executable option section |
| `#menuOptionsLabelGameExec` | Label for game executable option |
| `#menuOptionsDirGameExec` | Set game executable file browser |
| `#menuOptionsContainerGCJar` | Container for grasscutter jar option |
| `#menuOptionsLabelGCJar` | Label for grasscutter jar option |
| `#menuOptionsDirGCJar` | Set grasscutter jar file browser |
| `#menuOptionsContainerToggleEnc` | Container for toggle encryption option |
| `#menuOptionsLabelToggleEnc` | Label for toggle encryption option |
| `#menuOptionsButtonToggleEnc` | Toggle encryption button container |
| `#toggleEnc` | Toggle encryption button |
| `#menuOptionsContainerGCWGame` | Container for "grasscutter with game" option |
| `#menuOptionsLabelGCWDame` | Label for "grasscutter with game" option |
| `#menuOptionsCheckboxGCWGame` | Container for "grasscutter with game" option checkbox |
| `#gcWithGame` | Grasscutter with game checkbox |
| `#menuOptionsContainerThemes` | Container for themes section |
| `#menuOptionsLabelThemes` | Label for set themes option |
| `#menuOptionsSelectThemes` | Container for themes select menu |
| `#menuOptionsSelectMenuThemes` | Set theme select menu |
| `#menuOptionsContainerJavaPath` | Container for Java Path option |
| `#menuOptionsLabelJavaPath` | Label for Java path option |
| `#menuOptionsDirJavaPath` | Container for java path file browser |
| `#menuOptionsContainerBG` | Container for Background option |
| `#menuOptionsLabelBG` | Label for background option |
| `#menuOptionsDirBG` | Container for background url/local path option |
| `#menuOptionsContainerLang` | Container for language change option |
| `#menuOptionsLabelLang` | Label for language change option |
| `#menuOptionsSelectLang` | Container for language change select menu |
| `#menuOptionsSelectMenuLang` | Language select menu |
| `#DownloadProgress` | Download progress container |
| `#bottomSectionContainer` | Bottom section container |
| `#miniDownloadContainer` | Container for mini download |
## Classes
This is not full list of all classes, rather its list of classes for commonly used components that can not be accessed using element id system.
| .Class | Description |
|-----------------------------|---------------------------------------------------------|
| `.BigButton` | Class for all buttons |
| `.BigButtonText` | Text inside a button | |
| `.Checkbox` | Checkbox container |
| `.CheckboxDisplay` | Content of checkbox |
| `.DirInput` | Container for DirInput |
| `.FileSelectIcon` | Icon of DirInput |
| `.DownloadList` | List of all downloads |
| `.DownloadSection` | Container for each download |
| `.DownloadTitle` | Contains file download path and current status |
| `.DownloadPath` | Path of a download |
| `.DownloadStatus` | Status of a download |
| `.DownloadSectionInner` | Contains progressbar of the download section |
| `.HelpSection` | Container for help "?" circle button |
| `.HelpButton` | HelpButton itself |
| `.HelpContents` | Content of help button once expanded |
| `.MainProgressBarWrapper` | Container for MainProgressBar |
| `.ProgressBar` | ProgressBar (creativity left the brain) |
| `.InnerProgress` | ProgressBar percentage |
| `.MainProgressText` | Text for MainProgressBar |
| `.ProgressBarWrapper` | Container for ProgressBar |
| `.DownloadControls` | DownloadControls of ProgressBar |
| `.downloadStop` | Container for download stop icon (SVG) |
| `.ProgressText` | Text of the ProgressBar display current download status |
| `.TextInputWrapper` | Container for TextInput |
| `.TextClear` | Container for clear input content button |
| `.TextInputClear` | TextInput clear button icon (SVG) |
| `.Divider` | Container for line dividers |
| `.DividerLine` | Divider line itself |
| `.CommitAuthor` | Author of a commit |
| `.CommitMessage` | Message of a commit |

View File

@@ -1,9 +1,14 @@
# Troubleshooting
A guide dedicated for trying to troubleshoot Cultivation.
## The launcher doesn't appear to open.
Try running the launcher with **administrative privileges**.\
If this fixes your issue, you can force enable it in the **Compatability**\
tab for the launcher's executable.
## Unable to play on `localhost`.
Make sure your server is running with **encryption disabled**.\
Additionally, make sure Cultivation **is not using HTTPS**.
Make sure your server is running with **encryption disabled** and `useInRouting` to **false**.\
Additionally, make sure Cultivation **is set to not use HTTPS**.
## "I can't do anything requiring the internet after closing Cultivation!"
You probably didn't close Cultivation properly.\

View File

@@ -1,6 +1,6 @@
{
"name": "cultivation",
"version": "1.0.0",
"version": "1.0.2",
"private": true,
"dependencies": {
"@tauri-apps/api": "^1.0.0-rc.5",

1317
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,33 +14,33 @@ rust-version = "1.57"
[build-dependencies]
tauri-build = { version = "1.0.0-rc.8", features = [] }
[target.'cfg(windows)'.dependencies]
is_elevated = "0.1.2"
registry = "1.2.1"
[target.'cfg(unix)'.dependencies]
sudo = "0.6.0"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-rc.9", features = ["api-all", "updater"] }
tauri = { version = "1.0.0-rc.9", features = ["api-all"] }
# Access system process info.
sysinfo = "0.23.12"
sysinfo = "0.24.6"
# ZIP-archive library.
zip-extract = "0.1.1"
zip = "0.6.2"
# For creating a "global" downloads list.
lazy_static = "1.4.0"
# Access to the Windows Registry.
registry = "1.2.1"
once_cell = "1.13.0"
# Program opener.
open = "2.1.2"
duct = "0.13.5"
# Serialization.
serde_json = "1"
base64 = "0.13.0"
# System process elevation.
is_elevated = "0.1.2"
runas = "0.2.1"
# Dependencies for the HTTP(S) proxy.
http = "0.2"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 35 KiB

58
src-tauri/lang/chs.json Normal file
View File

@@ -0,0 +1,58 @@
{
"lang_name": "简体中文",
"main": {
"title": "Cultivation",
"launch_button": "启动",
"gc_enable": "以 Grasscutter 模式连接",
"https_enable": "使用 HTTPS",
"ip_placeholder": "IP 地址...",
"port_placeholder": "端口...",
"files_downloading": "文件下载中:",
"files_extracting": "文件解压中:"
},
"options": {
"game_exec": "选择游戏可执行文件",
"grasscutter_jar": "选择 Grasscutter JAR 文件",
"java_path": "设置自定义 Java 路径",
"grasscutter_with_game": "随游戏自动启动 Grasscutter",
"language": "语言",
"background": "设置自定义背景(链接或文件)",
"theme": "设置主题"
},
"downloads": {
"grasscutter_stable_data": "下载 Grasscutter 稳定版数据",
"grasscutter_latest_data": "下载 Grasscutter 开发版数据",
"grasscutter_stable_data_update": "更新 Grasscutter 稳定版数据",
"grasscutter_latest_data_update": "更新 Grasscutter 开发版数据",
"grasscutter_stable": "下载 Grasscutter 稳定版",
"grasscutter_latest": "下载 Grasscutter 开发版",
"grasscutter_stable_update": "更新 Grasscutter 稳定版",
"grasscutter_latest_update": "更新 Grasscutter 开发版",
"resources": "下载 Grasscutter 资源"
},
"download_status": {
"downloading": "下载中",
"extracting": "解压中",
"error": "错误",
"finished": "已完成",
"stopped": "已暂停"
},
"components": {
"select_file": "选择文件或文件夹...",
"select_folder": "选择文件夹...",
"download": "下载"
},
"news": {
"latest_commits": "最近的PR",
"latest_version": "最新版本"
},
"help": {
"port_help_text": "确保这是 Dispatch 服务器端口,而不是游戏服务器端口。大部分服务器的端口都是 443。",
"game_help_text": "你不需要另外的游戏备份来使用 Grasscutter。这是给想要降级到 2.6 或没有安装游戏的人使用的。",
"gc_stable_jar": "下载当前的 Grasscutter 稳定版,包括 JAR 文件和数据。",
"gc_dev_jar": "下载最新的 Grasscutter 开发版,包括 JAR 文件和数据。",
"gc_stable_data": "下载当前的 Grasscutter 稳定版数据,不包括 JAR 文件。此选项在更新时有帮助。",
"gc_dev_data": "下载最新的 Grasscutter 开发版数据,不包括 JAR 文件。此选项在更新时有帮助。",
"resources": "资源文件在运行 Grasscutter 服务器时是必要的。此选项在已经存在资源文件时不可选。"
}
}

61
src-tauri/lang/cht.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "繁體中文",
"main": {
"title": "Cultivation",
"launch_button": "啟動",
"gc_enable": "以Grasscutter模式連接",
"https_enable": "使用 HTTPS",
"ip_placeholder": "IP地址...",
"port_placeholder": "通訊埠...",
"files_downloading": "檔案下載中:",
"files_extracting": "檔案解壓縮中:"
},
"options": {
"enabled": "已啟用",
"disabled": "未啟用",
"game_exec": "選擇遊戲執行檔",
"grasscutter_jar": "選擇伺服器JAR檔案",
"toggle_encryption": "設定加密",
"java_path": "設定自定義Java路徑",
"grasscutter_with_game": "伴隨遊戲一起啟動Grasscutter",
"language": "語言",
"background": "設定自定義背景(網址或檔案)",
"theme": "設定主題"
},
"downloads": {
"grasscutter_stable_data": "下載Grasscutter穩定版數據Data",
"grasscutter_latest_data": "下載Grasscutter開發板數據Data",
"grasscutter_stable_data_update": "更新Grasscutter穩定版數據Data",
"grasscutter_latest_data_update": "更新Grasscutter開發板數據Data",
"grasscutter_stable": "下載Grasscutter穩定版",
"grasscutter_latest": "下載Grasscutter開發板",
"grasscutter_stable_update": "更新Grasscutter穩定版",
"grasscutter_latest_update": "更新Grasscutter開發板",
"resources": "下載Grasscutter資源Resources"
},
"download_status": {
"downloading": "下載中",
"extracting": "解壓縮中",
"error": "錯誤",
"finished": "已完成",
"stopped": "暫停"
},
"components": {
"select_file": "選擇檔案或資料夾...",
"select_folder": "選擇資料夾...",
"download": "下載"
},
"news": {
"latest_commits": "最近的PR",
"latest_version": "最新版本"
},
"help": {
"port_help_text": "確保這是Dispatch伺服器端口不是遊戲伺服器端口。 大部分伺服器的端口都是443。",
"game_help_text": "你不需要另外一個遊戲備份來使用Grasscutter。這是給想要降級到2.6或者還沒安裝遊戲的人使用的。",
"gc_stable_jar": "下載當前的Grasscutter穩定版本包括JAR答案還有資料文件。",
"gc_dev_jar": "下載當前的Grasscutter穩定版本資料文件其中不會附帶JAR文件。這個選項在更新時很有用。",
"gc_stable_data": "下載當前最新的Grasscutter開發版本資料文件其中不會附帶JAR文件。這個選項在更新時很有用。",
"gc_dev_data": "下載當前最新的Grasscutter開發版本的資料文件其中不會附帶JAR文件。這個選項在更新時很有用。",
"resources": "資源文件在架設一個Grasscutter伺服器時是必要的。 這個選項會在你已經有裡面有檔案的資源資料夾時不可選。"
}
}

61
src-tauri/lang/de.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "Deutsch",
"main": {
"title": "Cultivation",
"launch_button": "Starten",
"gc_enable": "Über Grasscutter verbinden",
"https_enable": "HTTPS nutzen",
"ip_placeholder": "Server Adresse...",
"port_placeholder": "Port...",
"files_downloading": "Herunterladen von Dateien: ",
"files_extracting": "Extrahieren von Dateien: "
},
"options": {
"enabled": "Aktiviert",
"disabled": "Deaktiviert",
"game_exec": "Spiel Datei auswählen",
"grasscutter_jar": "Grasscuter JAR auswählen",
"toggle_encryption": "Verschlüsselung umschalten",
"java_path": "Benutzerdefinierten Java Pfad setzen",
"grasscutter_with_game": "Grasscutter automatisch mit dem Spiel starten",
"language": "Sprache auswählen",
"background": "Benutzerdefinierten Hintergrund festlegen (link oder bild)",
"theme": "Theme auswählen"
},
"downloads": {
"grasscutter_stable_data": "Stabile Grasscutter Daten herunterladen",
"grasscutter_latest_data": "Aktuellste Grasscutter Daten herunterladen",
"grasscutter_stable_data_update": "Stabile Grasscutter Daten aktualisieren",
"grasscutter_latest_data_update": "Aktuellste Grasscutter Daten aktualisieren",
"grasscutter_stable": "Stabile Grasscutter Version herunterladen",
"grasscutter_latest": "Aktuellste Grasscutter Version herunterladen",
"grasscutter_stable_update": "Stabile Grasscutter Version aktualisieren",
"grasscutter_latest_update": "Aktuellste Grasscutter Version aktualisieren",
"resources": "Grasscutter Ressourcen herunterladen"
},
"download_status": {
"downloading": "Lädt herunter",
"extracting": "Extrahiert",
"error": "Fehler",
"finished": "Fertig",
"stopped": "Gestoppt"
},
"components": {
"select_file": "Datei oder Ordner auswählen...",
"select_folder": "Ordner auswählen...",
"download": "Herunterladen"
},
"news": {
"latest_commits": "Letzte Commits",
"latest_version": "Letzte Version"
},
"help": {
"port_help_text": "Vergewissern Sie sich, dass es sich um den Port des Dispatch-Servers handelt, nicht um den Port des Spiel-Servers. Dieser ist fast immer '443'.",
"game_help_text": "Sie müssen keine separate Kopie verwenden, um mit Grasscutter zu spielen. Dies ist entweder für ein Downgrade auf die Version 2.6 oder wenn Sie das Spiel nicht installiert haben.",
"gc_stable_jar": "Laden Sie den aktuellen stabilen Grasscutter-Build herunter, der eine Jar-Datei und Datendateien enthält.",
"gc_dev_jar": "Laden Sie die neueste Grasscutter-Entwicklungsversion herunter, welche eine Jar-Datei und Datendateien enthält.",
"gc_stable_data": "Laden Sie die stabilen Grasscutter Daten herunter, welche keine Jar-Datei enthalten. Dies ist nützlich zum Aktualisieren.",
"gc_dev_data": "Laden Sie die neuesten Grasscutter-Entwicklungsdateien herunter, welche keine Jar-Datei enthält. Dies ist nützlich zum Aktualisieren.",
"resources": "Diese werden auch benötigt, um einen Grasscutter-Server auszuführen. Diese Schaltfläche ist grau, wenn Sie einen bestehenden Ressourcenordner mit Inhalten haben"
}
}

View File

@@ -11,8 +11,11 @@
"files_extracting": "Files Extracting: "
},
"options": {
"enabled": "Enabled",
"disabled": "Disabled",
"game_exec": "Set Game Executable",
"grasscutter_jar": "Set Grasscutter JAR",
"toggle_encryption": "Toggle Encryption",
"java_path": "Set Custom Java Path",
"grasscutter_with_game": "Automatically launch Grasscutter with game",
"language": "Select Language",

61
src-tauri/lang/fr.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "Francais",
"main": {
"title": "Cultivation",
"launch_button": "Lancer",
"gc_enable": "Se connecter avec Grasscutter",
"https_enable": "Utiliser HTTPS",
"ip_placeholder": "Adresse du serveur...",
"port_placeholder": "Port...",
"files_downloading": "Fichiers en cours de telechargement: ",
"files_extracting": "Fichiers en cours d'extraction: "
},
"options": {
"enabled": "active",
"disabled": "desactiver",
"game_exec": "definir l'executable du jeu",
"grasscutter_jar": "definir le Jar Grasscutter",
"toggle_encryption": "activer l'encryption",
"java_path": "definir un chemin java personnalise",
"grasscutter_with_game": "Lancer Grasscutter automatiquement avec le jeu",
"language": "Choisir la langue",
"background": "definir un arriere plan personnalise (lien ou fichier image)",
"theme": "definir un theme"
},
"downloads": {
"grasscutter_stable_data": "Telecharger les donnees de Grasscutter (version stable)",
"grasscutter_latest_data": "Telecharger les donnees de Grasscutter (derniere version)",
"grasscutter_stable_data_update": "Mettre a jour les donnees de Grasscutter (version stable)",
"grasscutter_latest_data_update": "Mettre a jour les donnees de Grasscutter (derniere version)",
"grasscutter_stable": "Telecharger Grasscutter (version stable)",
"grasscutter_latest": "Telecharger Grasscutter (derniere version)",
"grasscutter_stable_update": "Mettre a jour Grasscutter (version stable)",
"grasscutter_latest_update": "Mettre a jour Grasscutter (derniere version)",
"resources": "Telecharger les ressources logicielles de Grasscutter"
},
"download_status": {
"downloading": "Telechargement",
"extracting": "Extraction",
"error": "Erreur",
"finished": "Termine",
"stopped": "Arrete"
},
"components": {
"select_file": "choisir fichier ou dossier...",
"select_folder": "choisir dossier...",
"download": "Telecharger"
},
"news": {
"latest_commits": "Recents Commits",
"latest_version": "Derniere version"
},
"help": {
"port_help_text": "Assurez-vous que c'est le port serveur Dispatch, et non le port du serveur de jeu. C'est presque toujours '433'.",
"game_help_text": "Vous n'avez pas besoin d'une copie differente du jeu pour jouer avec Grasscutter. Cela est ou pour retrograder en 2.6 ou si vous n'avez pas le jeu d'installe",
"gc_stable_jar": "Telecharger le dernier build stable de Grasscutter, ce qui inclut le fichier jar et les fichiers de donnees",
"gc_dev_jar": "Telecharger le dernier build en development de Grasscutter, ce qui inclut le fichier jar et les fichiers de donnees",
"gc_stable_data": "Telecharger le dernier build stable de Grasscutter, ce qui n'inclut pasle fichier jar. Cela est utile pour mettre a jour",
"gc_dev_data": "Telecharger le dernier build en development de Grasscutter, ce qui n'inclut pasle fichier jar. Cela est utile pour mettre a jour",
"resources": "Les ressources sont aussi necessaires pour lancer un serveur Grasscutter. Ce bouton deviendra gris si vous avez deja un fichier ressources avec les donnees dedans."
}
}

61
src-tauri/lang/lv.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "Latviešu",
"main": {
"title": "Cultivation",
"launch_button": "Palaist",
"gc_enable": "Savienot ar Grasscutter",
"https_enable": "Izm. HTTPS",
"ip_placeholder": "Servera Adrese...",
"port_placeholder": "Ports...",
"files_downloading": "Failu Lejupielāde: ",
"files_extracting": "Failu Izvilkšana: "
},
"options": {
"enabled": "Iespējots",
"disabled": "Atspējots",
"game_exec": "Iestatīt spēles izpildāmu",
"grasscutter_jar": "Iestatiet Grasscutter JAR",
"toggle_encryption": "Pārslēgt Šifrēšanu",
"java_path": "Iestatiet pielāgotu Java ceļu",
"grasscutter_with_game": "Automātiski palaidiet Grasscutter ar spēli",
"language": "Izvēlēties valodu",
"background": "Iestatīt pielāgotu fonu (saite vai attēla fails)",
"theme": "Iestatīt tēmu"
},
"downloads": {
"grasscutter_stable_data": "Lejupielādējiet Grasscutter stabilos datus",
"grasscutter_latest_data": "Lejupielādējiet Grasscutter jaunākos datus",
"grasscutter_stable_data_update": "Atjauniniet Grasscutter stabilos datus",
"grasscutter_latest_data_update": "Atjauniniet Grasscutter jaunākos datus",
"grasscutter_stable": "Lejupielādēt Grasscutter stabilo",
"grasscutter_latest": "Lejupielādēt Grasscutter jaunāko",
"grasscutter_stable_update": "Atjauniet Grasscutter stabilo",
"grasscutter_latest_update": "Atjauniet Grasscutter jaunāko",
"resources": "Lejupielādējiet Grasscutter resursi"
},
"download_status": {
"downloading": "Notiek lejupielāde",
"extracting": "Notiek izvilkšana",
"error": "Kļūda",
"finished": "Pabeigts",
"stopped": "Partraukta"
},
"components": {
"select_file": "Izvēlēties failu vai mapu...",
"select_folder": "Izvēlēties mapu...",
"download": "Lejupielādēt"
},
"news": {
"latest_commits": "Nesen kommitus",
"latest_version": "Jaunākā versija"
},
"help": {
"port_help_text": "Pārliecinieties, vai tas ir Dispatch-servera ports, nevis spēļu servera ports. Tas gandrīz vienmēr ir '443'.",
"game_help_text": "Lai spēlētu ar Grasscutter, jums nav jāizmanto atsevišķa kopija. Tas ir izveidots, lai pazeminātu versiju uz 2.6 vai ja jums nav instalēta spēle.",
"gc_stable_jar": "Lejupielādējiet pašreizējo stabilo Grasscutter versiju, kuram ir jar failu un datu failus.",
"gc_dev_jar": "Lejupielādējiet jaunāko izstrāde Grasscutter versiju, kuram ir jar failu un datu failus.",
"gc_stable_data": "Lejupielādējiet pašreizējos stabilos Grasscutter datu failus, kuriem nav jar fails. Tas ir noderīgi atjaunināšanai.",
"gc_dev_data": "Lejupielādējiet jaunāko izstrāde Grasscutter datu failus, kuriem nav pievienots jar fails. Tas ir noderīgi atjaunināšanai.",
"resources": "Tie ir nepieciešami arī Grasscutter servera darbināšanai. Šī poga būs pelēka, ja jums ir resursu mape ar saturu."
}
}

61
src-tauri/lang/ru.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "Русский",
"main": {
"title": "Cultivation",
"launch_button": "Запустить",
"gc_enable": "Подключиться с Grasscutter",
"https_enable": "Исп. HTTPS",
"ip_placeholder": "Айпи адрес...",
"port_placeholder": "Порт...",
"files_downloading": "Файлов скачано: ",
"files_extracting": "Извлечено файлов: "
},
"options": {
"enabled": "Включено",
"disabled": "Выключено",
"game_exec": "Установить исполняемый файл игры",
"grasscutter_jar": "Установить Grasscutter JAR",
"toggle_encryption": "Переключить шифрование",
"java_path": "Установить пользовательский путь Java",
"grasscutter_with_game": "Автоматически запускать Grasscutter вместе с игрой",
"language": "Установить язык",
"background": "Установить свой фон (ссылка или файл)",
"theme": "Установить тему"
},
"downloads": {
"grasscutter_stable_data": "Скачать стабильные данные Grasscutter",
"grasscutter_latest_data": "Скачать последние данные Grasscutter",
"grasscutter_stable_data_update": "Обновить стабильные данные Grasscutter",
"grasscutter_latest_data_update": "Обновить последние данные Grasscutter",
"grasscutter_stable": "Скачать стабильную версию Grasscutter",
"grasscutter_latest": "Скачать последнюю версию Grasscutter",
"grasscutter_stable_update": "Обновить стабильную версию Grasscutter",
"grasscutter_latest_update": "Обновить последнюю версию Grasscutter",
"resources": "Скачать ресурсы Grasscutter"
},
"download_status": {
"downloading": "Скачивание",
"extracting": "Извлечение",
"error": "Ошибка",
"finished": "Закончено",
"stopped": "Остановлено"
},
"components": {
"select_file": "Выберите файл или папку...",
"select_folder": "Выберите папку...",
"download": "Скачать"
},
"news": {
"latest_commits": "Последние коммиты",
"latest_version": "Последняя версия"
},
"help": {
"port_help_text": "Убедитесь, что это порт Dispatch-сервера, не порт игрового сервера. Обычно это '443'.",
"game_help_text": "Вам не нужно устанавливать еще одну копию, что бы играть с Grascutter. Это нужно или для версии 2.6, или если у Вас не установлена игра.",
"gc_stable_jar": "Скачать последнюю стабильную версию Grasscutter, которая содержит jar файл и данные.",
"gc_dev_jar": "Скачать последнюю версию для разработки Grasscutter, которая содержит jar файл и данные.",
"gc_stable_data": "Скачать стабильные данные Grasscutter, в которой нету jar файла. Это полезно для обновления.",
"gc_dev_data": "Скачать последнюю версию для разработки Grasscutter, в которой нету jar файла. Это полезно для обновления.",
"resources": "Это необходимо для запуска сервера Grasscutter. Эта кнопка будет серой, если у Вас уже есть не пустая папка с ресурсами."
}
}

61
src-tauri/lang/vi.json Normal file
View File

@@ -0,0 +1,61 @@
{
"lang_name": "Tiếng Việt",
"main": {
"title": "Cultivation",
"launch_button": "Khởi Chạy",
"gc_enable": "Kết nối đến Grasscutter",
"https_enable": "Sử dụng HTTPS",
"ip_placeholder": "Địa chỉ máy chủ...",
"port_placeholder": "Cổng...",
"files_downloading": "Đang tải file: ",
"files_extracting": "Đang giải nén tệp tin: "
},
"options": {
"enabled": "Bật",
"disabled": "Tắt",
"game_exec": "Đường dẫn đến GenshinImpact.exe",
"grasscutter_jar": "Đường dẫn đến Grasscutter.jar",
"toggle_encryption": "Bật/Tắt mã hoá",
"java_path": "Đường dẫn Java tuỳ chỉnh",
"grasscutter_with_game": "Tự động khởi chạy Grasscutter cùng game",
"language": "Chọn ngôn ngữ",
"background": "Ảnh nền tuỳ chỉnh (đường dẫn hoặc tệp tin ảnh)",
"theme": "Chọn giao diện"
},
"downloads": {
"grasscutter_stable_data": "Tải xuống dữ liệu Grasscutter bản ổn định",
"grasscutter_latest_data": "Tải xuống dữ liệu Grasscutter bản mới nhất",
"grasscutter_stable_data_update": "Cập nhật dữ liệu Grasscutter bản ổn định",
"grasscutter_latest_data_update": "Cập nhật dữ liệu Grasscutter bản mới nhất",
"grasscutter_stable": "Tải xuống Grasscutter phiên bản ổn định",
"grasscutter_latest": "Tải xuống Grasscutter phiển bản mới nhất",
"grasscutter_stable_update": "Cập nhật Grasscutter ổn định",
"grasscutter_latest_update": "Cập nhật Grasscutter mới nhất",
"resources": "Tải xuống tài nguyên cho Grasscutter"
},
"download_status": {
"downloading": "Đang tải",
"extracting": "Đang giải nén",
"error": "Lỗi",
"finished": "Đã xong",
"stopped": "Đã dừng"
},
"components": {
"select_file": "Chọn tệp tin hoặc thư mục...",
"select_folder": "Chọn thư mục...",
"download": "Tải xuống"
},
"news": {
"latest_commits": "Cập nhật gần đây",
"latest_version": "Phiên bản mới nhất"
},
"help": {
"port_help_text": "Đảm bảo đây là cổng của server Dispatch, không phải cổng của server Game. Thường là '443'.",
"game_help_text": "Bạn không cần phải sử dụng một bản sao riêng để chơi với Grasscutter. Việc này chỉ xảy ra nếu bạn hạ phiên bản xuống 2.6 hoặc chưa cài đặt trò chơi.",
"gc_stable_jar": "Tải xuống phiên bản ổn định của Grasscutter, bảo gồm file jar và các file dữ liệu.",
"gc_dev_jar": "Tải xuống phiên bản phát triển mới nhất của Grasscutter, bảo gồm file jar và các file dữ liệu.",
"gc_stable_data": "Tải xuống bản ổn định các tệp dữ liệu của Grasscutter, không bao gồm file jar. Phù hợp khi cập nhật.",
"gc_dev_data": "Tải xuống bản phát triển mới nhất các tệp dữ liệu của Grasscutter, không bao gồm file jar. Phù hợp khi cập nhật.",
"resources": "Chúng được yêu cầu để chạy máy chủ Grasscutter. Nút này sẽ có màu xám nếu bạn có một thư mục tài nguyên có nội dung bên trong"
}
}

View File

@@ -1,4 +1,4 @@
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::sync::Mutex;
use std::cmp::min;
@@ -8,12 +8,7 @@ use std::io::Write;
use futures_util::StreamExt;
// This will create a downloads list that will be used to check if we should continue downloading the file
lazy_static! {
static ref DOWNLOADS: Mutex<Vec<String>> = {
let m = Vec::new();
Mutex::new(m)
};
}
static DOWNLOADS: Lazy<Mutex<Vec<String>>> = Lazy::new(|| Mutex::new(Vec::new()));
// Lots of help from: https://gist.github.com/giuliano-oliveira/4d11d6b3bb003dba3a1b53f43d81b30d
// and docs ofc
@@ -59,17 +54,17 @@ pub async fn download_file(window: tauri::Window, url: &str, path: &str) -> Resu
let chunk = match item {
Ok(itm) => itm,
Err(e) => {
emit_download_err(window, format!("Error while downloading file"), path);
emit_download_err(window, "Error while downloading file".to_string(), path);
return Err(format!("Error while downloading file: {}", e));
}
};
let vect = &chunk.to_vec()[..];
// Write bytes
match file.write_all(&vect) {
match file.write_all(vect) {
Ok(x) => x,
Err(e) => {
emit_download_err(window, format!("Error while writing file"), path);
emit_download_err(window, "Error while writing file".to_string(), path);
return Err(format!("Error while writing file: {}", e));
}
}
@@ -78,7 +73,7 @@ pub async fn download_file(window: tauri::Window, url: &str, path: &str) -> Resu
let new = min(downloaded + (chunk.len() as u64), total_size);
downloaded = new;
total_downloaded = total_downloaded + chunk.len() as u64;
total_downloaded += chunk.len() as u64;
let mut res_hash = std::collections::HashMap::new();
@@ -110,15 +105,15 @@ pub async fn download_file(window: tauri::Window, url: &str, path: &str) -> Resu
window.emit("download_finished", &path).unwrap();
// We are done
return Ok(());
Ok(())
}
pub fn emit_download_err(window: tauri::Window, msg: std::string::String, path: &str) {
pub fn emit_download_err(window: tauri::Window, msg: String, path: &str) {
let mut res_hash = std::collections::HashMap::new();
res_hash.insert(
"error".to_string(),
msg.to_string(),
msg,
);
res_hash.insert(

View File

@@ -5,31 +5,51 @@ pub fn rename(path: String, new_name: String) {
let mut new_path = path.clone();
// Check if file/folder to replace exists
if !fs::metadata(&path).is_ok() {
if fs::metadata(&path).is_err() {
return;
}
// Check if path uses forward or back slashes
if new_path.contains("\\") {
new_path = path.replace("\\", "/");
if new_path.contains('\\') {
new_path = path.replace('\\', "/");
}
let path_replaced = &path.replace(&new_path.split("/").last().unwrap(), &new_name);
let path_replaced = &path.replace(&new_path.split('/').last().unwrap(), &new_name);
fs::rename(path, &path_replaced).unwrap();
}
#[tauri::command]
pub fn dir_exists(path: &str) -> bool {
return fs::metadata(&path).is_ok();
fs::metadata(&path).is_ok()
}
#[tauri::command]
pub fn dir_is_empty(path: &str) -> bool {
return fs::read_dir(&path).unwrap().count() == 0;
fs::read_dir(&path).unwrap().count() == 0
}
#[tauri::command]
pub fn dir_delete(path: &str) {
fs::remove_dir_all(path).unwrap();
}
}
#[tauri::command]
pub fn copy_file(path: String, new_path: String) -> bool {
let filename = &path.split("/").last().unwrap();
let mut new_path_buf = std::path::PathBuf::from(&new_path);
// If the new path doesn't exist, create it.
if !dir_exists(new_path_buf.pop().to_string().as_str()) {
std::fs::create_dir_all(&new_path).unwrap();
}
// Copy old to new
match std::fs::copy(&path, format!("{}/{}", new_path, filename)) {
Ok(_) => true,
Err(e) => {
println!("Failed to copy file: {}", e);
false
}
}
}

View File

@@ -1,3 +1,4 @@
use std::path::{Path, PathBuf};
use crate::system_helpers::*;
#[tauri::command]
@@ -5,15 +6,14 @@ pub async fn get_lang(window: tauri::Window, lang: String) -> String {
let lang = lang.to_lowercase();
// Send contents of language file back
let contents = match std::fs::read_to_string(format!("{}/lang/{}.json", install_location(), lang)) {
let lang_path: PathBuf = [&install_location(), "lang", &format!("{}.json", lang)].iter().collect();
match std::fs::read_to_string(&lang_path) {
Ok(x) => x,
Err(e) => {
emit_lang_err(window, format!("Failed to read language file: {}", e));
return "".to_string();
"".to_string()
}
};
return contents;
}
}
#[tauri::command]
@@ -21,14 +21,14 @@ pub async fn get_languages() -> std::collections::HashMap<String, String> {
// for each lang file, set the key as the filename and the value as the lang_name contained in the file
let mut languages = std::collections::HashMap::new();
let mut lang_files = std::fs::read_dir(format!("{}/lang", install_location())).unwrap();
let lang_files = std::fs::read_dir(Path::new(&install_location()).join("lang")).unwrap();
while let Some(entry) = lang_files.next() {
for entry in lang_files {
let entry = entry.unwrap();
let path = entry.path();
let filename = path.file_name().unwrap().to_str().unwrap();
let content = match std::fs::read_to_string(path.to_str().unwrap()) {
let content = match std::fs::read_to_string(&path) {
Ok(x) => x,
Err(e) => {
println!("Failed to read language file: {}", e);
@@ -39,15 +39,15 @@ pub async fn get_languages() -> std::collections::HashMap<String, String> {
languages.insert(filename.to_string(), content);
}
return languages;
languages
}
pub fn emit_lang_err(window: tauri::Window, msg: std::string::String) {
pub fn emit_lang_err(window: tauri::Window, msg: String) {
let mut res_hash = std::collections::HashMap::new();
res_hash.insert(
"error".to_string(),
msg.to_string(),
msg,
);
window.emit("lang_error", &res_hash).unwrap();

View File

@@ -3,8 +3,9 @@ all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::{sync::Mutex, collections::HashMap};
use std::path::PathBuf;
use std::thread;
use sysinfo::{System, SystemExt};
@@ -19,23 +20,12 @@ mod lang;
mod proxy;
mod web;
lazy_static! {
static ref WATCH_GAME_PROCESS: Mutex<String> = {
let m = "".to_string();
Mutex::new(m)
};
}
static WATCH_GAME_PROCESS: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(String::new()));
fn main() {
// Start the game process watcher.
process_watcher();
// Make BG folder if it doesn't exist.
let bg_folder = format!("{}/bg", system_helpers::install_location());
if !std::path::Path::new(&bg_folder).exists() {
std::fs::create_dir_all(&bg_folder).unwrap();
}
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
enable_process_watcher,
@@ -43,14 +33,12 @@ fn main() {
disconnect,
req_get,
get_bg_file,
base64_decode,
is_game_running,
get_theme_list,
system_helpers::run_command,
system_helpers::run_program,
system_helpers::run_jar,
system_helpers::open_in_browser,
system_helpers::copy_file,
system_helpers::install_location,
system_helpers::is_elevated,
proxy::set_proxy_addr,
@@ -60,6 +48,7 @@ fn main() {
file_helpers::dir_exists,
file_helpers::dir_is_empty,
file_helpers::dir_delete,
file_helpers::copy_file,
downloader::download_file,
downloader::stop_download,
lang::get_lang,
@@ -86,14 +75,9 @@ fn process_watcher() {
// Grab the game process name
let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string();
if !&proc.is_empty() {
let proc_with_name = system.processes_by_exact_name(&proc);
let mut exists = false;
for _p in proc_with_name {
exists = true;
break;
}
if !proc.is_empty() {
let mut proc_with_name = system.processes_by_exact_name(&proc);
let exists = proc_with_name.next().is_some();
// If the game process closes, disable the proxy.
if !exists {
@@ -111,7 +95,7 @@ fn is_game_running() -> bool {
// Grab the game process name
let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string();
return !proc.is_empty();
!proc.is_empty()
}
#[tauri::command]
@@ -142,11 +126,8 @@ fn disconnect() {
#[tauri::command]
async fn req_get(url: String) -> String {
// Send a GET request to the specified URL.
let response = web::query(&url.to_string()).await;
// Send the response body back to the client.
return response;
// Send a GET request to the specified URL and send the response body back to the client.
web::query(&url.to_string()).await
}
#[tauri::command]
@@ -182,13 +163,14 @@ async fn get_theme_list(data_dir: String) -> Vec<HashMap<String, String>> {
}
}
return themes;
themes
}
#[tauri::command]
// TODO: Replace with downloading the background file & saving it.
async fn get_bg_file(bg_path: String, appdata: String) -> String {
let copy_loc = appdata;
let query = web::query("https://api.grasscutters.xyz/cultivation/query").await;
let query = web::query("https://api.grasscutter.io/cultivation/query").await;
let response_data: APIQuery = match serde_json::from_str(&query) {
Ok(data) => data,
Err(e) => {
@@ -205,7 +187,7 @@ async fn get_bg_file(bg_path: String, appdata: String) -> String {
}
// Now we check if the bg folder, which is one directory above the game_path, exists.
let bg_img_path = format!("{}\\{}", bg_path.clone().to_string(), file_name.as_str());
let bg_img_path = format!("{}\\{}", &bg_path, &file_name);
// If it doesn't, then we do not have backgrounds to grab.
if !file_helpers::dir_exists(&bg_path) {
@@ -221,21 +203,15 @@ async fn get_bg_file(bg_path: String, appdata: String) -> String {
// The image exists, lets copy it to our local '\bg' folder.
let bg_img_path_local = format!("{}\\bg\\{}", copy_loc, file_name.as_str());
return match std::fs::copy(bg_img_path, bg_img_path_local) {
match std::fs::copy(bg_img_path, bg_img_path_local) {
Ok(_) => {
// Copy was successful, lets return true.
format!("{}\\{}", copy_loc, response_data.bg_file.as_str())
format!("{}\\{}", copy_loc, response_data.bg_file)
}
Err(e) => {
// Copy failed, lets return false
println!("Failed to copy background image: {}", e);
"".to_string()
}
};
}
}
#[tauri::command]
fn base64_decode(encoded: String) -> String {
let decoded = base64::decode(&encoded).unwrap();
return String::from_utf8(decoded).unwrap();
}

View File

@@ -3,7 +3,7 @@
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
*/
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::{sync::Mutex, str::FromStr};
use rcgen::*;
@@ -16,11 +16,13 @@ use hudsucker::{
use std::fs;
use std::net::SocketAddr;
use registry::{Hive, Data, Security};
use std::path::Path;
use rustls_pemfile as pemfile;
use tauri::http::Uri;
use crate::system_helpers::run_command;
#[cfg(windows)]
use registry::{Hive, Data, Security};
async fn shutdown_signal() {
tokio::signal::ctrl_c().await
@@ -28,12 +30,7 @@ async fn shutdown_signal() {
}
// Global ver for getting server address.
lazy_static! {
static ref SERVER: Mutex<String> = {
let m = "http://localhost:443".to_string();
Mutex::new(m)
};
}
static SERVER: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new("http://localhost:443".to_string()));
#[derive(Clone)]
struct ProxyHandler;
@@ -108,44 +105,50 @@ pub async fn create_proxy(proxy_port: u16, certificate_path: String) {
/**
* Connects to the local HTTP(S) proxy server.
*/
#[cfg(windows)]
pub fn connect_to_proxy(proxy_port: u16) {
if cfg!(target_os = "windows") {
// Create 'ProxyServer' string.
let server_string: String = format!("http=127.0.0.1:{};https=127.0.0.1:{}", proxy_port, proxy_port);
// Create 'ProxyServer' string.
let server_string: String = format!("http=127.0.0.1:{};https=127.0.0.1:{}", proxy_port, proxy_port);
// Fetch the 'Internet Settings' registry key.
let settings = Hive::CurrentUser.open(r"Software\Microsoft\Windows\CurrentVersion\Internet Settings", Security::Write).unwrap();
// Fetch the 'Internet Settings' registry key.
let settings = Hive::CurrentUser.open(r"Software\Microsoft\Windows\CurrentVersion\Internet Settings", Security::Write).unwrap();
// Set registry values.
settings.set_value("ProxyServer", &Data::String(server_string.parse().unwrap())).unwrap();
settings.set_value("ProxyEnable", &Data::U32(1)).unwrap();
}
// Set registry values.
settings.set_value("ProxyServer", &Data::String(server_string.parse().unwrap())).unwrap();
settings.set_value("ProxyEnable", &Data::U32(1)).unwrap();
println!("Connected to the proxy.");
}
#[cfg(not(windows))]
pub fn connect_to_proxy(_proxy_port: u16) {
println!("Connecting to the proxy is not implemented on this platform.");
}
/**
* Disconnects from the local HTTP(S) proxy server.
*/
#[cfg(windows)]
pub fn disconnect_from_proxy() {
if cfg!(target_os = "windows") {
// Fetch the 'Internet Settings' registry key.
let settings = Hive::CurrentUser.open(r"Software\Microsoft\Windows\CurrentVersion\Internet Settings", Security::Write).unwrap();
// Fetch the 'Internet Settings' registry key.
let settings = Hive::CurrentUser.open(r"Software\Microsoft\Windows\CurrentVersion\Internet Settings", Security::Write).unwrap();
// Set registry values.
settings.set_value("ProxyEnable", &Data::U32(0)).unwrap();
}
// Set registry values.
settings.set_value("ProxyEnable", &Data::U32(0)).unwrap();
println!("Disconnected from proxy.");
}
#[cfg(not(windows))]
pub fn disconnect_from_proxy() {}
/*
* Generates a private key and certificate used by the certificate authority.
* Additionally installs the certificate and private key in the Root CA store.
* Source: https://github.com/zu1k/good-mitm/raw/master/src/ca/gen.rs
*/
#[tauri::command]
pub fn generate_ca_files(path: &str) {
pub fn generate_ca_files(path: &Path) {
let mut params = CertificateParams::default();
let mut details = DistinguishedName::new();
@@ -166,14 +169,13 @@ pub fn generate_ca_files(path: &str) {
];
// Create certificate.
let cert_path = format!("{}\\ca", path);
let cert = Certificate::from_params(params).unwrap();
let cert_crt = cert.serialize_pem().unwrap();
let private_key = cert.serialize_private_key_pem();
// Make certificate directory.
match fs::create_dir(&cert_path) {
let cert_dir = path.join("ca");
match fs::create_dir(&cert_dir) {
Ok(_) => {},
Err(e) => {
println!("{}", e);
@@ -181,30 +183,39 @@ pub fn generate_ca_files(path: &str) {
};
// Write the certificate to a file.
match fs::write(format!("{}\\cert.crt", &cert_path), cert_crt) {
Ok(_) => println!("Wrote certificate to {}", &cert_path),
Err(e) => println!("Error writing certificate to {}: {}", &cert_path, e),
let cert_path = cert_dir.join("cert.crt");
match fs::write(&cert_path, cert_crt) {
Ok(_) => println!("Wrote certificate to {}", cert_path.to_str().unwrap()),
Err(e) => println!("Error writing certificate to {}: {}", cert_path.to_str().unwrap(), e),
}
// Write the private key to a file.
match fs::write(format!("{}\\private.key", &cert_path), private_key) {
Ok(_) => println!("Wrote private key to {}", &cert_path),
Err(e) => println!("Error writing private key to {}: {}", &cert_path, e),
let private_key_path = cert_dir.join("private.key");
match fs::write(&private_key_path, private_key) {
Ok(_) => println!("Wrote private key to {}", private_key_path.to_str().unwrap()),
Err(e) => println!("Error writing private key to {}: {}", private_key_path.to_str().unwrap(), e),
}
// Install certificate into the system's Root CA store.
install_ca_files(path);
install_ca_files(&cert_path);
}
/*
* Attempts to install the certificate authority's certificate into the Root CA store.
*/
pub fn install_ca_files(path: &str) {
if cfg!(target_os = "windows") {
run_command(format!("certutil -user -addstore \"Root\" {}\\ca\\cert.crt", path).to_string());
} else {
run_command(format!("security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain {}/ca/cert.crt", path).to_string());
}
#[cfg(windows)]
pub fn install_ca_files(cert_path: &Path) {
crate::system_helpers::run_command("certutil", vec!["-user", "-addstore", "Root", cert_path.to_str().unwrap()]);
println!("Installed certificate.");
}
}
#[cfg(target_os = "macos")]
pub fn install_ca_files(cert_path: &Path) {
crate::system_helpers::run_command("security", vec!["add-trusted-cert", "-d", "-r", "trustRoot", "-k", "/Library/Keychains/System.keychain", cert_path.to_str().unwrap()]);
println!("Installed certificate.");
}
#[cfg(not(any(windows, target_os = "macos")))]
pub fn install_ca_files(_cert_path: &Path) {
println!("Certificate installation is not supported on this platform.");
}

View File

@@ -1,36 +1,17 @@
use std::thread;
use std::process::Command;
use tauri;
use open;
use duct::cmd;
use crate::file_helpers;
#[tauri::command]
pub fn run_program(path: String) {
// Open the program from the specified path.
// Open in new thread to prevent blocking.
thread::spawn(move || {
open::that(&path).unwrap();
});
open::that(&path).unwrap();
}
#[tauri::command]
pub fn run_command(command: String) {
// Run the specified command.
if cfg!(target_os = "windows") {
Command::new("cmd")
.args(["/C", command.as_str()])
.output()
.expect("failed to execute process")
} else {
Command::new("sh")
.arg("-c")
.arg(command.as_str())
.output()
.expect("failed to execute process")
};
pub fn run_command(program: &str, args: Vec<&str>) {
cmd(program, args).run()
.expect("Failed to run command");
}
#[tauri::command]
@@ -42,7 +23,7 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) {
};
// Open the program from the specified path.
match open::with(format!("/k cd /D \"{}\" & {}", &execute_in, &command).to_string(), "C:\\Windows\\System32\\cmd.exe") {
match open::with(format!("/k cd /D \"{}\" & {}", &execute_in, &command), "C:\\Windows\\System32\\cmd.exe") {
Ok(_) => (),
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
};
@@ -57,25 +38,6 @@ pub fn open_in_browser(url: String) {
};
}
#[tauri::command]
pub fn copy_file(path: String, new_path: String) -> bool {
let filename = &path.split("/").last().unwrap();
let mut new_path_buf = std::path::PathBuf::from(&new_path);
// If the new path doesn't exist, create it.
if !file_helpers::dir_exists(new_path_buf.pop().to_string().as_str()) {
std::fs::create_dir_all(&new_path).unwrap();
}
// Copy old to new
match std::fs::copy(&path, format!("{}/{}", new_path, filename)) {
Ok(_) => true,
Err(e) => {
println!("Failed to copy file: {}", e);
false
}
}
}
#[tauri::command]
pub fn install_location() -> String {
@@ -87,7 +49,14 @@ pub fn install_location() -> String {
return exe_path.to_str().unwrap().to_string();
}
#[cfg(windows)]
#[tauri::command]
pub fn is_elevated() -> bool {
return is_elevated::is_elevated();
}
is_elevated::is_elevated()
}
#[cfg(unix)]
#[tauri::command]
pub fn is_elevated() -> bool {
sudo::check() == sudo::RunningAs::Root
}

View File

@@ -1,5 +1,3 @@
use zip_extract;
use zip;
use std::fs::File;
use std::path;
use std::thread;

View File

@@ -4,7 +4,7 @@ pub(crate) async fn query(site: &str) -> String {
let client = reqwest::Client::new();
let response = client.get(site).header(USER_AGENT, "cultivation").send().await.unwrap();
return response.text().await.unwrap();
response.text().await.unwrap()
}
#[tauri::command]
@@ -14,5 +14,5 @@ pub(crate) async fn valid_url(url: String) -> bool {
let response = client.get(url).header(USER_AGENT, "cultivation").send().await.unwrap();
return response.status().as_str() == "200";
response.status().as_str() == "200"
}

View File

@@ -7,7 +7,7 @@
},
"package": {
"productName": "Cultivation",
"version": "1.0.0"
"version": "1.0.2"
},
"tauri": {
"allowlist": {
@@ -72,10 +72,11 @@
"csp": "default-src 'self' https://asset.localhost; img-src 'self'; img-src https://* asset: https://asset.localhost"
},
"updater": {
"active": true,
"active": false,
"dialog": true,
"endpoints": [
"https://api.grasscutters.xyz/cultivation/update?version={{current_version}}"
"https://api.grasscutter.io/cultivation/updater?version={{current_version}}",
"https://api.grasscutters.xyz/cultivation/updater?version={{current_version}}"
],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEIyM0MzMzk0NkM4OTQzNQpSV1ExbE1oR09jTWpDNFJ4NURsaS9mdHpDWmpBM3JNVHkrdER4bS9KdHFCQnNVSWs0ZjZTU295WAo="
},

View File

@@ -3,20 +3,27 @@ import ReactDOM from 'react-dom/client'
import './index.css'
import App from './ui/App'
// import Debug from './ui/Debug'
import Debug from './ui/Debug'
import { getConfigOption } from './utils/configuration'
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
)
let isDebug = false;
(async() => {
isDebug = await getConfigOption('debug_enabled')
})
root.render(
<React.StrictMode>
<App />
{
isDebug ? <Debug /> : <App />
}
</React.StrictMode>
)
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
import reportWebVitals from './utils/reportWebVitals'
reportWebVitals(console.log)
isDebug && reportWebVitals(console.log)

View File

@@ -36,7 +36,7 @@ interface IState {
bgFile: string;
}
const DEFAULT_BG = 'https://api.grasscutters.xyz/content/bgfile'
const DEFAULT_BG = 'https://api.grasscutter.io/cultivation/bgfile'
const downloadHandler = new DownloadHandler()
@@ -79,7 +79,6 @@ class App extends React.Component<IProps, IState> {
async componentDidMount() {
const cert_generated = await getConfigOption('cert_generated')
const game_exe = await getConfigOption('game_install_path')
const custom_bg = await getConfigOption('customBackground')
const game_path = game_exe?.substring(0, game_exe.replace(/\\/g, '/').lastIndexOf('/')) || ''
const root_path = game_path?.substring(0, game_path.replace(/\\/g, '/').lastIndexOf('/')) || ''
@@ -90,6 +89,9 @@ class App extends React.Component<IProps, IState> {
await loadTheme(themeObj, document)
}
// Get custom bg AFTER theme is loaded !! important !!
const custom_bg = await getConfigOption('customBackground')
if(!custom_bg || !/png|jpg|jpeg$/.test(custom_bg)) {
if(game_path) {
// Get the bg by invoking, then set the background to that bg.
@@ -164,7 +166,7 @@ class App extends React.Component<IProps, IState> {
{
// Mini downloads section
this.state.miniDownloadsOpen ? (
<div className="MiniDownloads">
<div className="MiniDownloads" id="miniDownloadContainer">
<MiniDialog
title="Downloads"
closeFn={() => {
@@ -207,7 +209,7 @@ class App extends React.Component<IProps, IState> {
) : null
}
<div className="BottomSection">
<div className="BottomSection" id="bottomSectionContainer">
<ServerLaunchSection />
<div id="DownloadProgress"

View File

@@ -32,16 +32,16 @@ export default class MiniDialog extends React.Component<IProps, never> {
render() {
return (
<div className="MiniDialog">
<div className="MiniDialog" id="miniDialogContainer">
{
this.props.closeable !== undefined && this.props.closeable ?
<div className="MiniDialogTop" onClick={this.props.closeFn}>
<div className="MiniDialogTop" id="miniDialogContainerTop" onClick={this.props.closeFn}>
<span>{this.props?.title}</span>
<img src={Close} className="MiniDialogClose" />
<img src={Close} className="MiniDialogClose" id="miniDialogButtonClose" />
</div> : null
}
<div className="MiniDialogInner">
<div className="MiniDialogInner" id="miniDialogContent">
{this.props.children}
</div>
</div>

View File

@@ -16,12 +16,12 @@ export default class RightBar extends React.Component {
render() {
return (
<div className="RightBar">
<div className="RightBarInner">
<div className="BarDiscord BarImg" onClick={() => this.openInBrowser(DISCORD)}>
<div className="RightBar" id="rightBarContainer">
<div className="RightBarInner" id="rightBarContent">
<div className="BarDiscord BarImg" id="rightBarButtonDiscord" onClick={() => this.openInBrowser(DISCORD)}>
<img src={Discord} />
</div>
<div className="BarGithub BarImg" onClick={() => this.openInBrowser(GITHUB)}>
<div className="BarGithub BarImg" id="rightBarButtonGithub" onClick={() => this.openInBrowser(GITHUB)}>
<img src={Github} />
</div>
</div>

View File

@@ -196,7 +196,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
{
this.state.grasscutterEnabled && (
<div>
<div className="ServerConfig">
<div className="ServerConfig" id="serverConfigContainer">
<TextInput id="ip" key="ip" placeholder={this.state.ipPlaceholder} onChange={this.setIp} initalValue={this.state.ip} />
<TextInput style={{
width: '10%',
@@ -210,10 +210,10 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
}
<div className="ServerLaunchButtons">
<div className="ServerLaunchButtons" id="serverLaunchContainer">
<BigButton onClick={this.playGame} id="officialPlay">{this.state.buttonLabel}</BigButton>
<BigButton onClick={this.launchServer} id="serverLaunch">
<img className="ServerIcon" src={Server} />
<img className="ServerIcon" id="serverLaunchIcon" src={Server} />
</BigButton>
</div>
</div>

View File

@@ -43,14 +43,14 @@ export default class TopBar extends React.Component<IProps, IState> {
render() {
return (
<div className="TopBar" data-tauri-drag-region>
<div className="TopBar" id="topBarContainer" data-tauri-drag-region>
<div id="title">
<span data-tauri-drag-region>
<Tr text="main.title" />
</span>
<span data-tauri-drag-region id="version">{this.state?.version}</span>
</div>
<div className="TopBtns">
<div className="TopBtns" id="topBarButtonContainer">
<div id="closeBtn" onClick={this.handleClose} className='TopButton'>
<img src={closeIcon} alt="close" />
</div>

View File

@@ -190,8 +190,8 @@ export default class Downloads extends React.Component<IProps, IState> {
render() {
return (
<Menu closeFn={this.props.closeFn} className="Downloads" heading="Downloads">
<div className='DownloadMenuSection'>
<div className='DownloadLabel'>
<div className='DownloadMenuSection' id="downloadMenuContainerGCStable">
<div className='DownloadLabel' id="downloadMenuLabelGCStable">
<Tr text={
this.state.grasscutter_set ? 'downloads.grasscutter_stable' : 'downloads.grasscutter_stable_update'
} />
@@ -199,14 +199,14 @@ export default class Downloads extends React.Component<IProps, IState> {
<Tr text="help.gc_stable_jar" />
</HelpButton>
</div>
<div className='DownloadValue'>
<div className='DownloadValue' id="downloadMenuButtonGCStable">
<BigButton disabled={this.state.grasscutter_downloading} onClick={this.downloadGrasscutterStable} id="grasscutterStableBtn" >
<Tr text="components.download" />
</BigButton>
</div>
</div>
<div className='DownloadMenuSection'>
<div className='DownloadLabel'>
<div className='DownloadMenuSection' id="downloadMenuContainerGCDev">
<div className='DownloadLabel' id="downloadMenuLabelGCDev">
<Tr text={
this.state.grasscutter_set ? 'downloads.grasscutter_latest' : 'downloads.grasscutter_latest_update'
} />
@@ -214,7 +214,7 @@ export default class Downloads extends React.Component<IProps, IState> {
<Tr text="help.gc_dev_jar" />
</HelpButton>
</div>
<div className='DownloadValue'>
<div className='DownloadValue' id="downloadMenuButtonGCDev">
<BigButton disabled={this.state.grasscutter_downloading} onClick={this.downloadGrasscutterLatest} id="grasscutterLatestBtn" >
<Tr text="components.download" />
</BigButton>
@@ -223,8 +223,8 @@ export default class Downloads extends React.Component<IProps, IState> {
<Divider />
<div className='DownloadMenuSection'>
<div className='DownloadLabel'>
<div className='DownloadMenuSection' id="downloadMenuContainerGCStableData">
<div className='DownloadLabel' id="downloadMenuLabelGCStableData">
<Tr text={
this.state.grasscutter_set ? 'downloads.grasscutter_stable_data' : 'downloads.grasscutter_stable_data_update'
} />
@@ -232,14 +232,14 @@ export default class Downloads extends React.Component<IProps, IState> {
<Tr text="help.gc_stable_data" />
</HelpButton>
</div>
<div className='DownloadValue'>
<div className='DownloadValue' id="downloadMenuButtonGCStableData">
<BigButton disabled={this.state.repo_downloading} onClick={this.downloadGrasscutterStableRepo} id="grasscutterStableRepo" >
<Tr text="components.download" />
</BigButton>
</div>
</div>
<div className='DownloadMenuSection'>
<div className='DownloadLabel'>
<div className='DownloadMenuSection' id="downloadMenuContainerGCDevData">
<div className='DownloadLabel' id="downloadMenuLabelGCDevData">
<Tr text={
this.state.grasscutter_set ? 'downloads.grasscutter_latest_data' : 'downloads.grasscutter_latest_data_update'
} />
@@ -247,7 +247,7 @@ export default class Downloads extends React.Component<IProps, IState> {
<Tr text="help.gc_dev_data" />
</HelpButton>
</div>
<div className='DownloadValue'>
<div className='DownloadValue' id="downloadMenuButtonGCDevData">
<BigButton disabled={this.state.repo_downloading} onClick={this.downloadGrasscutterStableRepo} id="grasscutterDevRepo" >
<Tr text="components.download" />
</BigButton>
@@ -256,14 +256,14 @@ export default class Downloads extends React.Component<IProps, IState> {
<Divider />
<div className='DownloadMenuSection'>
<div className='DownloadLabel'>
<div className='DownloadMenuSection' id="downloadMenuContainerResources">
<div className='DownloadLabel' id="downloadMenuLabelResources">
<Tr text="downloads.resources" />
<HelpButton>
<Tr text="help.resources" />
</HelpButton>
</div>
<div className='DownloadValue'>
<div className='DownloadValue' id="downloadMenuButtonResources">
<BigButton disabled={this.state.resources_downloading || !this.state.grasscutter_set || this.state.resources_exist} onClick={this.downloadResources} id="resourcesBtn" >
<Tr text="components.download" />
</BigButton>

View File

@@ -17,14 +17,14 @@ export default class Menu extends React.Component<IProps, never> {
render() {
return (
<div className={'Menu ' + this.props.className}>
<div className='MenuTop'>
<div className="MenuHeading">{this.props.heading}</div>
<div className="MenuExit" onClick={this.props.closeFn}>
<img src={Close} className="MenuClose" />
<div className={'Menu ' + this.props.className} id="menuContainer">
<div className='MenuTop' id="menuContainerTop">
<div className="MenuHeading" id="menuHeading">{this.props.heading}</div>
<div className="MenuExit" id="menuButtonCloseContainer" onClick={this.props.closeFn}>
<img src={Close} className="MenuClose" id="menuButtonCloseIcon" />
</div>
</div>
<div className='MenuInner'>
<div className='MenuInner' id="menuContent">
{this.props.children}
</div>
</div>

View File

@@ -6,4 +6,13 @@
margin-bottom: 8px;
width: 80%;
}
.OptionSection .BigButton {
height: 100%;
min-height: 30px;
}
.OptionSection .BigButtonText {
font-size: 12px;
}

View File

@@ -3,13 +3,15 @@ import { invoke } from '@tauri-apps/api'
import { dataDir } from '@tauri-apps/api/path'
import DirInput from '../common/DirInput'
import Menu from './Menu'
import Tr, { getLanguages } from '../../../utils/language'
import Tr, { getLanguages, translate } from '../../../utils/language'
import { setConfigOption, getConfig, getConfigOption } from '../../../utils/configuration'
import Checkbox from '../common/Checkbox'
import Divider from './Divider'
import { getThemeList } from '../../../utils/themes'
import * as server from '../../../utils/server'
import './Options.css'
import BigButton from '../common/BigButton'
interface IProps {
closeFn: () => void;
@@ -25,6 +27,7 @@ interface IState {
bg_url_or_path: string
themes: string[]
theme: string
encryption: boolean
}
export default class Options extends React.Component<IProps, IState> {
@@ -40,7 +43,8 @@ export default class Options extends React.Component<IProps, IState> {
current_language: 'en',
bg_url_or_path: '',
themes: ['default'],
theme: ''
theme: '',
encryption: false
}
this.setGameExec = this.setGameExec.bind(this)
@@ -48,11 +52,17 @@ export default class Options extends React.Component<IProps, IState> {
this.setJavaPath = this.setJavaPath.bind(this)
this.toggleGrasscutterWithGame = this.toggleGrasscutterWithGame.bind(this)
this.setCustomBackground = this.setCustomBackground.bind(this)
this.toggleEncryption = this.toggleEncryption.bind(this)
}
async componentDidMount() {
const config = await getConfig()
const languages = await getLanguages()
// Remove jar from path
const path = config.grasscutter_path.replace(/\\/g, '/')
const folderPath = path.substring(0, path.lastIndexOf('/'))
const encEnabled = await server.encryptionEnabled(folderPath + '/config.json')
this.setState({
game_install_path: config.game_install_path || '',
@@ -63,7 +73,8 @@ export default class Options extends React.Component<IProps, IState> {
current_language: config.language || 'en',
bg_url_or_path: config.customBackground || '',
themes: (await getThemeList()).map(t => t.name),
theme: config.theme || 'default'
theme: config.theme || 'default',
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled')
})
this.forceUpdate()
@@ -136,45 +147,77 @@ export default class Options extends React.Component<IProps, IState> {
}
}
async toggleEncryption() {
const config = await getConfig()
// Check if grasscutter path is set
if (!config.grasscutter_path) {
alert('Grasscutter not set!')
return
}
// Remove jar from path
const path = config.grasscutter_path.replace(/\\/g, '/')
const folderPath = path.substring(0, path.lastIndexOf('/'))
await server.toggleEncryption(folderPath + '/config.json')
this.setState({
encryption: await translate(await server.encryptionEnabled(folderPath + '/config.json') ? 'options.enabled' : 'options.disabled')
})
}
render() {
return (
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerGameExec">
<div className='OptionLabel' id="menuOptionsLabelGameExec">
<Tr text="options.game_exec" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsDirGameExec">
<DirInput onChange={this.setGameExec} value={this.state?.game_install_path} extensions={['exe']} />
</div>
</div>
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerGCJar">
<div className='OptionLabel' id="menuOptionsLabelGCJar">
<Tr text="options.grasscutter_jar" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsDirGCJar">
<DirInput onChange={this.setGrasscutterJar} value={this.state?.grasscutter_path} extensions={['jar']} />
</div>
</div>
<div className='OptionSection' id="menuOptionsContainerToggleEnc">
<div className='OptionLabel' id="menuOptionsLabelToggleEnc">
<Tr text="options.toggle_encryption" />
</div>
<div className='OptionValue' id="menuOptionsButtonToggleEnc">
<BigButton onClick={this.toggleEncryption} id="toggleEnc">
{
this.state.encryption
}
</BigButton>
</div>
</div>
<Divider />
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerGCWGame">
<div className='OptionLabel' id="menuOptionsLabelGCWDame">
<Tr text="options.grasscutter_with_game" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsCheckboxGCWGame">
<Checkbox onChange={this.toggleGrasscutterWithGame} checked={this.state?.grasscutter_with_game} id="gcWithGame" />
</div>
</div>
<Divider />
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerThemes">
<div className='OptionLabel' id="menuOptionsLabelThemes">
<Tr text="options.theme" />
</div>
<div className='OptionValue'>
<select value={this.state.theme} onChange={(event) => {
<div className='OptionValue' id="menuOptionsSelectThemes">
<select value={this.state.theme} id="menuOptionsSelectMenuThemes" onChange={(event) => {
this.setTheme(event.target.value)
}}>
{this.state.themes.map(t => (
@@ -191,20 +234,20 @@ export default class Options extends React.Component<IProps, IState> {
<Divider />
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerJavaPath">
<div className='OptionLabel' id="menuOptionsLabelJavaPath">
<Tr text="options.java_path" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsDirJavaPath">
<DirInput onChange={this.setJavaPath} value={this.state?.java_path} extensions={['exe']} />
</div>
</div>
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerBG">
<div className='OptionLabel' id="menuOptionsLabelBG">
<Tr text="options.background" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsDirBG">
<DirInput
onChange={this.setCustomBackground}
value={this.state?.bg_url_or_path}
@@ -219,12 +262,12 @@ export default class Options extends React.Component<IProps, IState> {
</div>
</div>
<div className='OptionSection'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerLang">
<div className='OptionLabel' id="menuOptionsLabelLang">
<Tr text="options.language" />
</div>
<div className='OptionValue'>
<select value={this.state.current_language} onChange={(event) => {
<div className='OptionValue' id="menuOptionsSelectLang">
<select value={this.state.current_language} id="menuOptionsSelectMenuLang" onChange={(event) => {
this.setLanguage(event.target.value)
}}>
{this.state.language_options.map(lang => (

View File

@@ -42,7 +42,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
async showLatestCommits() {
if (!this.state.commitList) {
const commits: string = await invoke('req_get', { url: 'https://api.grasscutters.xyz/cultivation/query' })
const commits: string = await invoke('req_get', { url: 'https://api.grasscutter.io/cultivation/query' })
let obj
try {
@@ -56,9 +56,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
const commits: string = await invoke('req_get', { url: 'https://api.github.com/repos/Grasscutters/Grasscutter/commits' })
obj = JSON.parse(commits)
} else {
const decoded: string = await invoke('base64_decode', { encoded: obj.commits })
const commitData = JSON.parse(decoded)
obj = commitData.gc_stable
obj = obj.commits.gc_stable
}
// Probably rate-limited
@@ -68,7 +66,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
const commitsList = obj.slice(0, 10)
const commitsListHtml = commitsList.map((commit: any) => {
return (
<tr className="Commit" key={commit.sha}>
<tr className="Commit" id="newsCommitsTable" key={commit.sha}>
<td className="CommitAuthor"><span>{commit.commit.author.name}</span></td>
<td className="CommitMessage"><span>{commit.commit.message}</span></td>
</tr>
@@ -108,8 +106,8 @@ export default class NewsSection extends React.Component<IProps, IState> {
render() {
return (
<div className="NewsSection">
<div className="NewsTabs">
<div className="NewsSection" id="newsContainer">
<div className="NewsTabs" id="newsTabsContainer">
<div className={'NewsTab ' + (this.state.selected === 'commits' ? 'selected' : '')} id="commits" onClick={() => this.setSelected('commits')}>
<Tr text="news.latest_commits" />
</div>
@@ -117,7 +115,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
<Tr text="news.latest_version" />
</div>
</div>
<table className="NewsContent">
<table className="NewsContent" id="newsContent">
<tbody>
{this.state.news}
</tbody>

View File

@@ -20,6 +20,7 @@ let defaultConfig: Configuration
cert_generated: false,
theme: 'default',
https_enabled: false,
debug_enabled: false
}
})()
@@ -39,8 +40,9 @@ export interface Configuration {
language: string
customBackground: string
cert_generated: boolean
theme: string;
theme: string
https_enabled: boolean
debug_enabled: boolean
}
export async function setConfigOption(key: string, value: any): Promise<void> {
@@ -52,8 +54,9 @@ export async function setConfigOption(key: string, value: any): Promise<void> {
export async function getConfigOption(key: string): Promise<any> {
const config: any = await getConfig()
const defaults: any = defaultConfig
return config[key] || null
return config[key] || defaults[key]
}
export async function getConfig() {
@@ -81,7 +84,7 @@ export async function saveConfig(obj: Configuration) {
async function readConfigFile() {
const local = await dataDir()
if (!configFilePath) configFilePath = local + 'cultivation\\configuration.json'
if (!configFilePath) configFilePath = local + 'cultivation/configuration.json'
// Ensure Cultivation dir exists
const dirs = await fs.readDir(local)
@@ -91,12 +94,12 @@ async function readConfigFile() {
await fs.createDir(local + 'cultivation').catch(e => console.log(e))
}
const innerDirs = await fs.readDir(local + '\\cultivation')
const innerDirs = await fs.readDir(local + '/cultivation')
// Create grasscutter dir for potential installation
if (!innerDirs.find((fileOrDir) => fileOrDir?.name === 'grasscutter')) {
// Create dir
await fs.createDir(local + 'cultivation\\grasscutter').catch(e => console.log(e))
await fs.createDir(local + 'cultivation/grasscutter').catch(e => console.log(e))
}
const dataFiles = await fs.readDir(local + 'cultivation')

36
src/utils/server.ts Normal file
View File

@@ -0,0 +1,36 @@
import { fs } from '@tauri-apps/api'
export async function toggleEncryption(path: string) {
let serverConf
try {
serverConf = JSON.parse(await fs.readTextFile(path))
} catch(e) {
console.log(`Server config at ${path} not found or invalid`)
return
}
const enabled = serverConf.server.http.encryption.useEncryption
serverConf.server.http.encryption.useEncryption = !enabled
serverConf.server.http.encryption.useInRouting = !enabled
// Write file
await fs.writeFile({
path,
contents: JSON.stringify(serverConf)
})
}
export async function encryptionEnabled(path: string) {
let serverConf
try {
serverConf = JSON.parse(await fs.readTextFile(path))
} catch(e) {
console.log(`Server config at ${path} not found or invalid`)
return false
}
return serverConf.server.http.encryption.useEncryption
}

View File

@@ -1,6 +1,7 @@
import { invoke } from '@tauri-apps/api'
import { dataDir } from '@tauri-apps/api/path'
import { convertFileSrc } from '@tauri-apps/api/tauri'
import { getConfig, setConfigOption } from './configuration'
interface Theme {
name: string
@@ -77,6 +78,9 @@ export async function getTheme(name: string) {
}
export async function loadTheme(theme: ThemeList, document: Document) {
// Get config, since we will set the custom background in there
const config = await getConfig()
// We are going to dynamically load stylesheets into the document
const head = document.head
@@ -107,22 +111,32 @@ export async function loadTheme(theme: ThemeList, document: Document) {
// Set custom background
if (theme.customBackgroundURL) {
document.body.style.backgroundImage = `url('${theme.customBackgroundURL}')`
// If the custom bg is already set don't overwrite
if (config.customBackground === '') {
config.customBackground = theme.customBackgroundURL
}
}
// Set custom background
if (theme.customBackgroundPath) {
const bgPath = await dataDir() + 'cultivation/grasscutter/theme.png'
const bgPath = (await dataDir()).replace(/\\/g, '/') + 'cultivation/bg/'
const imageName = theme.customBackgroundPath.split('/').pop()
// Save the background to our data dir
await invoke('copy_file', {
path: theme.path + '/' + theme.customBackgroundPath,
new_path: bgPath
newPath: bgPath
})
// Set the background
document.body.style.backgroundImage = `url('${bgPath}')`
// If the custom bg is already set don't overwrite
if (config.customBackground === '') {
config.customBackground = bgPath + imageName
}
}
// Write config
await setConfigOption('customBackground', config.customBackground)
return
}

12483
yarn.lock

File diff suppressed because it is too large Load Diff