Skip to content

Commit

Permalink
Add delay button for 3dmigoto
Browse files Browse the repository at this point in the history
  • Loading branch information
NotThorny committed Apr 7, 2023
1 parent 72d0af5 commit 37173c2
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src-tauri/lang/chs.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "资源文件在运行 Grasscutter 服务器时是必要的。此选项在已经存在资源文件时不可选。",
"emergency_rsa": "在出现意外情况时自动将 RSA 恢复到原始版本",
"use_proxy": "使用 Cultivation 的内置代理。除非你使用 Fiddler 等软件,否则应启用此项。",
"patch_rsa": "自动修改和恢复 RSA 补丁。 除非您玩的是旧版/非官方版本,或者您手动修改了 RSA,否则应该启用此功能。"
"patch_rsa": "自动修改和恢复 RSA 补丁。 除非您玩的是旧版/非官方版本,或者您手动修改了 RSA,否则应该启用此功能。",
"add_delay": "在 3dmigoto 加载程序中设置延迟! \n这应该可以解决加载问题,但会在启动游戏时加载 3dmigoto 时增加一点延迟。 \n您现在可以再次使用 3dmigoto 启动。"
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/cht.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "資源文件在架設一個Grasscutter伺服器時是必要的。 這個選項會在您已經有裡面有檔案的資源資料夾時不可選。",
"emergency_rsa": "一旦有東西出了問題,此選項可以把您的rsa恢復成官方版本。",
"use_proxy": "使用Cultivation內建的代理伺服器。此選項應該被啟用,除非你使用其他的代理伺服器。",
"patch_rsa": "自動修補和恢復RSA。除非您的遊戲版本是舊的或者是非官方的,此選項應該被啟用。"
"patch_rsa": "自動修補和恢復RSA。除非您的遊戲版本是舊的或者是非官方的,此選項應該被啟用。",
"add_delay": "在 3dmigoto 加載程序中設置延遲! \n這應該可以解決加載問題,但會在啟動遊戲時加載 3dmigoto 時增加一點延遲。 \n您現在可以再次使用 3dmigoto 啟動。"
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"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",
"emergency_rsa": "Im Fall, dass etwas schief laufen sollte, kannst du deine RSA auf die letzte offizielle Version zurücksetzen",
"use_proxy": "Nutze den internen Proxy von Cultivation. Du solltest dies aktivieren, es sei denn du nutzt Programme wie Fiddler",
"patch_rsa": "Patche und aktualisiere deine RSA automatisch. Solange du nicht mit einer alten/nicht offiziellen Version spielst oder deine RSA manuell gepatcht hast, sollte dies aktiviert sein."
"patch_rsa": "Patche und aktualisiere deine RSA automatisch. Solange du nicht mit einer alten/nicht offiziellen Version spielst oder deine RSA manuell gepatcht hast, sollte dies aktiviert sein.",
"add_delay": "Verzögerung im 3dmigoto-Lader einstellen! \nDies sollte die Ladeprobleme beheben, führt aber zu einer kleinen Verzögerung, wenn 3dmigoto beim Start des Spiels geladen wird. \nSie können nun wieder mit 3dmigoto starten."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "These are also required to run a Grasscutter server. This button will be grey if you have an existing resources folder with contents inside",
"emergency_rsa": "In case something went wrong, force delete RSA patch.",
"use_proxy": "Use the Cultivation internal proxy. You should have this enabled unless you use something like Fiddler",
"patch_rsa": "Patch and unpatch your game RSA automatically. Unless playing with old/non-official versions (3.0 and older), this should be enabled."
"patch_rsa": "Patch and unpatch your game RSA automatically. Unless playing with old/non-official versions (3.0 and older), this should be enabled.",
"add_delay": "Set delay in 3dmigoto loader! \nThis should fix loading issues, but will add a small delay to when 3dmigoto is loaded upon launching the game. \nYou can now launch with 3dmigoto again."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"gc_dev_jar": "Descargue la última versión de Desarrollo de Grasscutter, que incluye archivos jar y archivos de datos.",
"gc_stable_data": "Descargue los archivos de Datos Estables actuales de Grasscutter, que no vienen con un archivo jar. Esto es útil para actualizar.",
"gc_dev_data": "Descargue los últimos archivos de Datos de Desarrollo de Grasscutter, que no vienen con un archivo jar. Esto es útil para actualizar.",
"resources": "Estos también son necesarios para ejecutar un servidor Grasscutter. Este botón estará gris si tiene una carpeta de recursos existente con contenido dentro."
"resources": "Estos también son necesarios para ejecutar un servidor Grasscutter. Este botón estará gris si tiene una carpeta de recursos existente con contenido dentro.",
"add_delay": "¡Retraso en el cargador de 3dmigoto! \nEsto debería solucionar los problemas de carga, pero añadirá un pequeño retraso cuando 3dmigoto se cargue al iniciar el juego. \nAhora puede iniciar con 3dmigoto de nuevo."
},
"swag": {
"akebi": "Establecer el ejecutable de Akebi"
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"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."
"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.",
"add_delay": "Définir un délai dans le chargeur de 3dmigoto ! \nCela devrait résoudre les problèmes de chargement, mais ajoutera un petit délai au chargement de 3dmigoto lors du lancement du jeu. \nVous pouvez maintenant lancer le jeu avec 3dmigoto."
}
}
3 changes: 2 additions & 1 deletion src-tauri/lang/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"gc_dev_jar": "Unduh Build Development Grasscutter saat ini, Dimana Ada Jar File Dan Data File.",
"gc_stable_data": "Unduh file data Grasscutter stabil saat ini, dimana Tidak Ada JAR file. Ini Berguna Untuk memperbarui.",
"gc_dev_data": "Unduh file data Grasscutter Development saat ini, dimana Tidak Ada JAR file. Ini Berguna Untuk memperbarui.",
"resources": "Ini juga diperlukan untuk menjalankan server Grasscutter. Tombol ini akan berwarna abu-abu jika Anda memiliki folder Resource yang ada dengan File di dalamnya"
"resources": "Ini juga diperlukan untuk menjalankan server Grasscutter. Tombol ini akan berwarna abu-abu jika Anda memiliki folder Resource yang ada dengan File di dalamnya",
"add_delay": "Atur penundaan di pemuat 3dmigoto! \nIni akan memperbaiki masalah pemuatan, tetapi akan menambah sedikit penundaan ketika 3dmigoto dimuat saat meluncurkan game. \nAnda sekarang dapat meluncurkan dengan 3dmigoto lagi."
}
}
3 changes: 2 additions & 1 deletion src-tauri/lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "또한 Grasscutter 서버를 실행하는 데도 필요합니다. 내용이 포함된 기존 리소스 폴더가 있는 경우 이 버튼은 회색으로 표시됩니다",
"emergency_rsa": "문제가 있는 경우 RSA 패치를 제거하십시오.",
"use_proxy": "Culturation 내부 프록시를 사용합니다. 피들러와 같은 것을 사용하지 않는 한 이 기능을 활성화해야 합니다",
"patch_rsa": "게임 RSA를 자동으로 패치 및 패치 해제합니다. 이전/비공식 버전을 사용하거나 RSA를 수동으로 패치하지 않은 경우 이 기능을 활성화해야 합니다."
"patch_rsa": "게임 RSA를 자동으로 패치 및 패치 해제합니다. 이전/비공식 버전을 사용하거나 RSA를 수동으로 패치하지 않은 경우 이 기능을 활성화해야 합니다.",
"add_delay": "3dmigoto 로더에서 지연을 설정하세요! \n이렇게하면 로딩 문제가 해결되지만 게임을 시작할 때 3dmigoto가로드되는시기에 약간의 지연이 추가됩니다. \n이제 3dmigoto로 다시 시작할 수 있습니다."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"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."
"resources": "Tie ir nepieciešami arī Grasscutter servera darbināšanai. Šī poga būs pelēka, ja jums ir resursu mape ar saturu.",
"add_delay": "Iestatiet kavēšanos 3dmigoto iekrāvē! \nTam vajadzētu novērst ielādes problēmas, bet tas nedaudz aizkavēs 3dmigoto ielādēšanu, uzsākot spēli. \nTagad atkal varat sākt ar 3dmigoto."
}
}
3 changes: 2 additions & 1 deletion src-tauri/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"resources": "Deze zijn ook nodig om een Grasscutter server te draaien. Deze knop zal grijs zijn als u een bestaande resources map heeft met inhoud erin",
"emergency_rsa": "Voor het geval er iets fout is gegaan, herstel uw rsa naar de laatste offici�le versies rsa.",
"use_proxy": "Gebruik de Cultivation interne proxy. U zou dit ingeschakeld moeten hebben, tenzij u iets als Fiddler gebruikt",
"patch_rsa": "Patch en unpatch je spel rsa automatisch. Tenzij je met oude/niet-offici�le versies speelt, of je hebt je rsa handmatig gepatcht, zou dit ingeschakeld moeten zijn."
"patch_rsa": "Patch en unpatch je spel rsa automatisch. Tenzij je met oude/niet-offici�le versies speelt, of je hebt je rsa handmatig gepatcht, zou dit ingeschakeld moeten zijn.",
"add_delay": "Vertraging instellen in 3dmigoto loader! \nDit zou laadproblemen moeten oplossen, maar zal een kleine vertraging toevoegen aan het laden van 3dmigoto bij het opstarten van het spel. \nJe kunt nu weer starten met 3dmigoto."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "Esses também são necessários para usar o Grasscutter. Esse botão ficará cinza caso você já tenha uma pasta resources com coisas dentro.",
"emergency_rsa": "Caso algo dê errado, força a exclusão da correção RSA.",
"use_proxy": "Usa o proxy interno do Cultivation. Isso deveria estar habilitado a não ser que você utilize algo como o Fiddler.",
"patch_rsa": "Corrigir e 'descorrigir' o RSA do seu jogo automaticamente. Isso deve estar habilitado a não ser que você esteja jogando com versões antigas (3.0 ou mais antigas) ou não oficiais."
"patch_rsa": "Corrigir e 'descorrigir' o RSA do seu jogo automaticamente. Isso deve estar habilitado a não ser que você esteja jogando com versões antigas (3.0 ou mais antigas) ou não oficiais.",
"add_delay": "Atraso definido na carregadeira 3dmigoto! \nIsto deve resolver os problemas de carregamento, mas acrescentará um pequeno atraso quando o 3dmigoto for carregado no lançamento do jogo. \nAgora você pode lançar novamente com o 3dmigoto."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"resources": "Это необходимо для запуска сервера Grasscutter. Эта кнопка будет серой, если у Вас уже есть не пустая папка с ресурсами.",
"emergency_rsa": "Если что-то пошло не так, восстановит RSA до последней официальной версии.",
"use_proxy": "Использовать встроенный Прокси. Отключите если используете Fiddler или подобную программу",
"patch_rsa": "Патчит и восстанавливает RSA автоматически. Если вы не играете на старых/модифицированых версиях, или сами в ручную патчите Метаданные, эта опция должна быть включена."
"patch_rsa": "Патчит и восстанавливает RSA автоматически. Если вы не играете на старых/модифицированых версиях, или сами в ручную патчите Метаданные, эта опция должна быть включена.",
"add_delay": "Установите задержку в загрузчике 3dmigoto! \nЭто должно исправить проблемы с загрузкой, но добавит небольшую задержку в момент загрузки 3dmigoto при запуске игры. \nТеперь вы снова можете запускать игру с помощью 3dmigoto."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/lang/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"resources": "Tài nguyên đượ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ó sẵn một thư mục tài nguyên (resources) có nội dung bên trong",
"emergency_rsa": "Trong trường hợp gặp vấn đề, khôi phục lại RSA về phiên bản chính thức mới nhất.",
"use_proxy": "Sử dụng proxy nội bộ của Cultivation. Nên bật tùy chọn này trừ khi bạn đang sử dụng một ứng dụng khác, như Fiddler",
"patch_rsa": "Tự động vá và sửa lại RSA của game. Tùy chọn này nên được bật trừ khi bạn đang sử dụng phiên bản cũ, phiên bản không chính thức hoặc bạn đã tự vá rsa rồi."
"patch_rsa": "Tự động vá và sửa lại RSA của game. Tùy chọn này nên được bật trừ khi bạn đang sử dụng phiên bản cũ, phiên bản không chính thức hoặc bạn đã tự vá rsa rồi.",
"add_delay": "Đặt độ trễ trong trình tải 3dmigoto! \nĐiều này sẽ khắc phục sự cố tải, nhưng sẽ thêm một độ trễ nhỏ khi 3dmigoto được tải khi khởi chạy trò chơi. \nBây giờ bạn có thể khởi chạy lại với 3dmigoto."
},
"swag": {
"akebi_name": "Akebi",
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn main() {
system_helpers::install_location,
system_helpers::is_elevated,
system_helpers::set_migoto_target,
system_helpers::set_migoto_delay,
system_helpers::wipe_registry,
system_helpers::get_platform,
proxy::set_proxy_addr,
Expand Down
36 changes: 36 additions & 0 deletions src-tauri/src/system_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,42 @@ pub fn set_migoto_target(window: tauri::Window, migoto_path: String) -> bool {
}
}

#[tauri::command]
pub fn set_migoto_delay(migoto_path: String) -> bool {
let mut migoto_pathbuf = PathBuf::from(migoto_path);

migoto_pathbuf.pop();
migoto_pathbuf.push("d3dx.ini");

let mut conf = match Ini::load_from_file(&migoto_pathbuf) {
Ok(c) => {
println!("Loaded migoto ini");
c
}
Err(e) => {
println!("Error loading migoto config: {}", e);
return false;
}
};

// Set options
conf
.with_section(Some("Loader"))
.set("delay", "20");

// Write file
match conf.write_to_file(&migoto_pathbuf) {
Ok(_) => {
println!("Wrote delay!");
true
}
Err(e) => {
println!("Error writing delay: {}", e);
false
}
}
}

#[cfg(windows)]
#[tauri::command]
pub fn wipe_registry(exec_name: String) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/common/DirInput.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DirInput {
display: flex;
display:inline-flex;
flex-direction: row;
align-items: center;
justify-content: center;
Expand Down
32 changes: 32 additions & 0 deletions src/ui/components/common/SmallButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.SmallButtonSection {
display: inline-block;
margin-left: 20px;
vertical-align: middle;
}

.SmallButtonButton {
height: 20px;
filter: drop-shadow(0px 0px 5px rgb(0 0 0 / 20%));
}

.SmallButtonButton:hover {
cursor: pointer;
}

.SmallButtonButton img {
height: 100%;
}

.SmallButtonContents {
text-align: center;
position: relative;
}

.SmallButtonContents .MiniDialog {
position: absolute;

bottom: 40px;
right: -450%;
width: 200px;
height: 120px;
}
39 changes: 39 additions & 0 deletions src/ui/components/common/SmallButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react'

import './SmallButton.css'
import Wrench from '../../../resources/icons/wrench.svg'
import { translate } from '../../../utils/language'

interface IProps {
children?: React.ReactNode[] | React.ReactNode
onClick: () => unknown
id?: string
contents?: string
}

export default class SmallButton extends React.Component<IProps> {
constructor(props: IProps) {
super(props)

this.handleClick = this.handleClick.bind(this)
}

async showAlert() {
if (this.props.contents) alert(await translate(this.props.contents))
}

handleClick() {
this.props.onClick()
this.showAlert()
}

render() {
return (
<div className="SmallButtonSection">
<div className="SmallButtonButton" onClick={this.handleClick}>
<img src={Wrench} />
</div>
</div>
)
}
}
10 changes: 10 additions & 0 deletions src/ui/components/menu/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import DownloadHandler from '../../../utils/download'
import * as meta from '../../../utils/rsa'
import HelpButton from '../common/HelpButton'
import TextInput from '../common/TextInput'
import SmallButton from '../common/SmallButton'

interface IProps {
closeFn: () => void
Expand Down Expand Up @@ -85,6 +86,7 @@ export default class Options extends React.Component<IProps, IState> {
this.setCustomBackground = this.setCustomBackground.bind(this)
this.toggleEncryption = this.toggleEncryption.bind(this)
this.removeRSA = this.removeRSA.bind(this)
this.addMigotoDelay = this.addMigotoDelay.bind(this)
}

async componentDidMount() {
Expand Down Expand Up @@ -278,6 +280,12 @@ export default class Options extends React.Component<IProps, IState> {
await meta.unpatchGame()
}

async addMigotoDelay() {
invoke('set_migoto_delay', {
migotoPath: this.state.migoto_path,
})
}

async installCert() {
await invoke('generate_ca_files', {
path: (await dataDir()) + 'cultivation',
Expand Down Expand Up @@ -422,6 +430,8 @@ export default class Options extends React.Component<IProps, IState> {
<Tr text="swag.migoto" />
</div>
<div className="OptionValue" id="menuOptionsDirMigoto">
<SmallButton onClick={this.addMigotoDelay} id="migotoDelay" contents='help.add_delay'>
</SmallButton>
<DirInput onChange={this.setMigoto} value={this.state?.migoto_path} extensions={['exe']} />
</div>
</div>
Expand Down

0 comments on commit 37173c2

Please sign in to comment.