1
1
import beautify from 'json-beautify' ;
2
2
import path from 'path-browserify' ;
3
3
import { toast } from 'svelte-sonner' ;
4
- import Roblox from '.' ;
5
4
import { getValue } from '../../components/settings' ;
6
5
import { Notification } from '../tools/notifications' ;
7
6
import { RPCController } from '../tools/rpc' ;
@@ -11,6 +10,10 @@ import { sleep } from '../utils';
11
10
import { focusWindow , setWindowVisibility } from '../window' ;
12
11
import onGameEvent from './events' ;
13
12
import { RobloxInstance } from './instance' ;
13
+ import { RobloxFFlags } from './fflags' ;
14
+ import { robloxPath } from './path' ;
15
+ import { RobloxUtils } from './utils' ;
16
+ import { RobloxMods } from './mods' ;
14
17
15
18
let rbxInstance : RobloxInstance | null = null ;
16
19
@@ -44,28 +47,28 @@ export async function launchRoblox(
44
47
try {
45
48
console . info ( '[Launch] Launching Roblox' ) ;
46
49
setLaunchingRoblox ( true ) ;
47
- if ( ! ( await Roblox . Utils . hasRoblox ( ) ) ) {
50
+ if ( ! ( await RobloxUtils . hasRoblox ( ) ) ) {
48
51
console . info ( '[Launch] Roblox is not installed. Exiting launch process.' ) ;
49
52
setLaunchingRoblox ( false ) ;
50
53
return ;
51
54
}
52
55
53
56
// Fast Flags
54
57
setLaunchProgress ( 20 ) ;
55
- if ( await shellFS . exists ( path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) ) ) {
58
+ if ( await shellFS . exists ( path . join ( robloxPath , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) ) ) {
56
59
console . info (
57
- `[Launch] Removing current ClientAppSettings.json file in "${ path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/ClientAppSettings.json"' ) } `
60
+ `[Launch] Removing current ClientAppSettings.json file in "${ path . join ( robloxPath , 'Contents/MacOS/ClientSettings/ClientAppSettings.json"' ) } `
58
61
) ;
59
- await shellFS . remove ( path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/' ) ) ;
62
+ await shellFS . remove ( path . join ( robloxPath , 'Contents/MacOS/ClientSettings/' ) ) ;
60
63
setLaunchText ( 'Removing current ClientAppSettings...' ) ;
61
64
}
62
65
63
66
setLaunchProgress ( 30 ) ;
64
67
setLaunchText ( 'Copying fast flags...' ) ;
65
68
console . info ( '[Launch] Copying fast flags...' ) ;
66
- await shellFS . createDirectory ( path . join ( Roblox . path , 'Contents/MacOS/ClientSettings' ) ) ;
69
+ await shellFS . createDirectory ( path . join ( robloxPath , 'Contents/MacOS/ClientSettings' ) ) ;
67
70
console . info ( '[Launch] Parsing saved FFlags...' ) ;
68
- const presetFlags = await Roblox . FFlags . parseFlags ( true ) ;
71
+ const presetFlags = await RobloxFFlags . parseFlags ( true ) ;
69
72
// Invalid presets
70
73
if (
71
74
Object . keys ( presetFlags . invalidFlags ) . length > 0 &&
@@ -82,7 +85,7 @@ export async function launchRoblox(
82
85
return ;
83
86
}
84
87
}
85
- const editorFlags = await Roblox . FFlags . parseFlags ( false ) ;
88
+ const editorFlags = await RobloxFFlags . parseFlags ( false ) ;
86
89
// Invalid selected profile flags
87
90
if (
88
91
Object . keys ( editorFlags . invalidFlags ) . length > 0 &&
@@ -126,29 +129,29 @@ export async function launchRoblox(
126
129
} ;
127
130
console . info ( '[Launch] FastFlags: ' , fflags ) ;
128
131
await shellFS . writeFile (
129
- path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) ,
132
+ path . join ( robloxPath , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) ,
130
133
JSON . stringify ( fflags )
131
134
) ;
132
135
console . info (
133
- `[Launch] Wrote FFlags to "${ path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) } "`
136
+ `[Launch] Wrote FFlags to "${ path . join ( robloxPath , 'Contents/MacOS/ClientSettings/ClientAppSettings.json' ) } "`
134
137
) ;
135
138
136
139
// Mods
137
140
if ( constSettings . areModsEnabled ) {
138
141
setLaunchProgress ( 40 ) ;
139
142
setLaunchText ( 'Copying Mods...' ) ;
140
143
141
- await Roblox . Mods . copyToFiles ( ) ;
144
+ await RobloxMods . copyToFiles ( ) ;
142
145
}
143
- await Roblox . Mods . applyCustomFont ( ) ;
146
+ await RobloxMods . applyCustomFont ( ) ;
144
147
145
148
setLaunchProgress ( 60 ) ;
146
149
setTimeout ( async ( ) => {
147
150
try {
151
+ await RobloxMods . toggleHighRes ( ! constSettings . fixResolution ) ;
148
152
if ( constSettings . areModsEnabled && constSettings . fixResolution ) {
149
153
setLaunchText ( 'Disabling Retina resolution...' ) ;
150
154
setLaunchProgress ( 80 ) ;
151
- await Roblox . Mods . toggleHighRes ( false ) ;
152
155
}
153
156
const robloxInstance = new RobloxInstance ( true ) ;
154
157
await robloxInstance . init ( ) ;
@@ -170,17 +173,15 @@ export async function launchRoblox(
170
173
subtitle : 'Quitting the app may corrupt Roblox' ,
171
174
timeout : 5 ,
172
175
} ) . show ( ) ;
173
- Roblox . Mods . restoreRobloxFolders ( )
176
+ RobloxMods . restoreRobloxFolders ( )
174
177
. catch ( console . error )
175
178
. then ( async ( ) => {
176
- console . info (
177
- `[Launch] Removed mod files from "${ path . join ( Roblox . path , 'Contents/Resources/' ) } "`
178
- ) ;
179
+ console . info ( `[Launch] Removed mod files from "${ path . join ( robloxPath , 'Contents/Resources/' ) } "` ) ;
179
180
// Use if block because checking if high resolution is enabled require file operations, so it's more optimized that way.
180
181
if ( constSettings . fixResolution ) {
181
- await Roblox . Mods . toggleHighRes ( true ) ;
182
+ await RobloxMods . toggleHighRes ( true ) ;
182
183
}
183
- await Roblox . Mods . removeCustomFont ( ) ;
184
+ await RobloxMods . removeCustomFont ( ) ;
184
185
} ) ;
185
186
}
186
187
RPCController . stop ( ) ;
@@ -191,17 +192,17 @@ export async function launchRoblox(
191
192
} ) ;
192
193
} catch ( err ) {
193
194
if ( constSettings . areModsEnabled ) {
194
- await Roblox . Mods . restoreRobloxFolders ( )
195
+ await RobloxMods . restoreRobloxFolders ( )
195
196
. catch ( console . error )
196
197
. then ( ( ) => {
197
- console . info ( `[Launch] Removed mod files from "${ path . join ( Roblox . path , 'Contents/Resources/' ) } "` ) ;
198
+ console . info ( `[Launch] Removed mod files from "${ path . join ( robloxPath , 'Contents/Resources/' ) } "` ) ;
198
199
} ) ;
199
200
}
200
201
console . error ( err ) ;
201
202
setLaunchingRoblox ( false ) ;
202
203
toast . error ( 'An error occured while starting Roblox.' ) ;
203
- await shellFS . remove ( path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/' ) ) ;
204
- console . info ( `[Launch] Deleted "${ path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/' ) } "` ) ;
204
+ await shellFS . remove ( path . join ( robloxPath , 'Contents/MacOS/ClientSettings/' ) ) ;
205
+ console . info ( `[Launch] Deleted "${ path . join ( robloxPath , 'Contents/MacOS/ClientSettings/' ) } "` ) ;
205
206
return ;
206
207
}
207
208
@@ -210,8 +211,8 @@ export async function launchRoblox(
210
211
setWindowVisibility ( false ) ;
211
212
setTimeout ( ( ) => {
212
213
setLaunchingRoblox ( false ) ;
213
- shellFS . remove ( path . join ( Roblox . path , 'Contents/MacOS/ClientSettings/' ) ) ;
214
- console . info ( `[Launch] Deleted "${ path . join ( Roblox . path , 'Contents/MacOS/ClientSettings' ) } "` ) ;
214
+ shellFS . remove ( path . join ( robloxPath , 'Contents/MacOS/ClientSettings/' ) ) ;
215
+ console . info ( `[Launch] Deleted "${ path . join ( robloxPath , 'Contents/MacOS/ClientSettings' ) } "` ) ;
215
216
} , 1000 ) ;
216
217
} , 1000 ) ;
217
218
} catch ( err ) {
0 commit comments