This commit is contained in:
SpikeHD
2022-07-09 22:52:04 -07:00
33 changed files with 7594 additions and 7116 deletions

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)

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,6 +1,6 @@
{
"name": "cultivation",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"dependencies": {
"@tauri-apps/api": "^1.0.0-rc.5",

1269
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,22 +14,26 @@ 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"] }
# 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"
@@ -37,11 +41,6 @@ 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"

View File

@@ -11,13 +11,16 @@
"files_extracting": "檔案解壓縮中:"
},
"options": {
"enabled": "已啟用",
"disabled": "未啟用",
"game_exec": "選擇遊戲執行檔",
"grasscutter_jar": "選擇伺服器JAR檔案",
"java_path": "設置自定義Java路徑",
"toggle_encryption": "設定加密",
"java_path": "設定自定義Java路徑",
"grasscutter_with_game": "伴隨遊戲一起啟動Grasscutter",
"language": "語言",
"background": "設自定義背景(網址或檔案)",
"theme": "設主題"
"background": "設自定義背景(網址或檔案)",
"theme": "設主題"
},
"downloads": {
"grasscutter_stable_data": "下載Grasscutter穩定版數據Data",

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"
}
}

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,28 +5,28 @@ 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]

View File

@@ -7,15 +7,13 @@ pub async fn get_lang(window: tauri::Window, lang: String) -> String {
// Send contents of language file back
let lang_path: PathBuf = [&install_location(), "lang", &format!("{}.json", lang)].iter().collect();
let contents = match std::fs::read_to_string(&lang_path) {
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]
@@ -23,9 +21,9 @@ 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(Path::new(&install_location()).join("lang")).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();
@@ -41,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,7 +3,7 @@ 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;
@@ -20,12 +20,7 @@ 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.
@@ -38,7 +33,6 @@ fn main() {
disconnect,
req_get,
get_bg_file,
base64_decode,
is_game_running,
get_theme_list,
system_helpers::run_command,
@@ -81,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 {
@@ -106,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]
@@ -137,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]
@@ -177,7 +163,7 @@ async fn get_theme_list(data_dir: String) -> Vec<HashMap<String, String>> {
}
}
return themes;
themes
}
#[tauri::command]
@@ -201,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) {
@@ -217,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::*;
@@ -17,11 +17,12 @@ use hudsucker::{
use std::fs;
use std::net::SocketAddr;
use std::path::Path;
use registry::{Hive, Data, Security};
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
@@ -29,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;
@@ -109,37 +105,43 @@ 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.
@@ -201,12 +203,19 @@ pub fn generate_ca_files(path: &Path) {
/*
* Attempts to install the certificate authority's certificate into the Root CA store.
*/
#[cfg(windows)]
pub fn install_ca_files(cert_path: &Path) {
if cfg!(target_os = "windows") {
run_command("certutil", vec!["-user", "-addstore", "Root", cert_path.to_str().unwrap()]);
} else {
run_command("security", vec!["add-trusted-cert", "-d", "-r", "trustRoot", "-k", "/Library/Keychains/System.keychain", cert_path.to_str().unwrap()]);
}
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,7 +1,3 @@
use std::thread;
use tauri;
use open;
use duct::cmd;
use crate::file_helpers;
@@ -9,11 +5,7 @@ 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]
@@ -31,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),
};
@@ -46,6 +38,7 @@ pub fn open_in_browser(url: String) {
};
}
#[tauri::command]
pub fn install_location() -> String {
let mut exe_path = std::env::current_exe().unwrap();
@@ -56,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.1"
},
"tauri": {
"allowlist": {

View File

@@ -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

@@ -170,27 +170,27 @@ export default class Options extends React.Component<IProps, IState> {
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'>
<div className='OptionLabel'>
<div className='OptionSection' id="menuOptionsContainerToggleEnc">
<div className='OptionLabel' id="menuOptionsLabelToggleEnc">
<Tr text="options.toggle_encryption" />
</div>
<div className='OptionValue'>
<div className='OptionValue' id="menuOptionsButtonToggleEnc">
<BigButton onClick={this.toggleEncryption} id="toggleEnc">
{
this.state.encryption
@@ -201,23 +201,23 @@ export default class Options extends React.Component<IProps, IState> {
<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 => (
@@ -234,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}
@@ -262,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

@@ -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

@@ -84,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)
@@ -94,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')

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