installer: .mc_custom 에 .minecraft 기존 설정 파일 복사
options.txt, optionsof.txt, servers.dat, usercache.json 등 .minecraft 최상위 파일을 .mc_custom 으로 복사해 사용자가 기존에 만들어둔 키바인딩/볼륨/렌더거리/ 서버목록을 음악퀴즈 인스턴스에서도 그대로 사용할 수 있도록 한다. 이미 .mc_custom 에 같은 이름의 파일이 있으면 보존(덮어쓰지 않음). 디렉터리는 복사 대상에서 제외(mods/saves/versions/assets 등은 별도 처리).
This commit is contained in:
@@ -783,6 +783,10 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
|||||||
await fsp.mkdir(path.join(customRoot, 'mods'), { recursive: true })
|
await fsp.mkdir(path.join(customRoot, 'mods'), { recursive: true })
|
||||||
await fsp.mkdir(path.join(customRoot, 'resourcepacks'), { recursive: true })
|
await fsp.mkdir(path.join(customRoot, 'resourcepacks'), { recursive: true })
|
||||||
|
|
||||||
|
// 사용자가 기존 .minecraft 에 저장해둔 설정(options.txt, servers.dat 등)을
|
||||||
|
// .mc_custom 으로 가져온다. 이미 있는 파일은 보존.
|
||||||
|
await copyMinecraftUserSettings(customRoot)
|
||||||
|
|
||||||
if (payload.installPlatform && pack.pack.platform.type === 'fabric') {
|
if (payload.installPlatform && pack.pack.platform.type === 'fabric') {
|
||||||
await installFabricLoader(pack.pack, customRoot)
|
await installFabricLoader(pack.pack, customRoot)
|
||||||
} else if (payload.installPlatform && pack.pack.platform.type !== 'vanilla' && pack.pack.platform.downloadUrl) {
|
} else if (payload.installPlatform && pack.pack.platform.type !== 'vanilla' && pack.pack.platform.downloadUrl) {
|
||||||
@@ -1048,6 +1052,43 @@ async function updateLauncherProfile(pack: PackDefinition, gameDir: string): Pro
|
|||||||
sendLog(`launcher_profiles.json 갱신: 프로필 "${profileKey}", gameDir=${gameDir}`)
|
sendLog(`launcher_profiles.json 갱신: 프로필 "${profileKey}", gameDir=${gameDir}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사용자가 기존에 .minecraft 에 만들어둔 설정 파일들(options.txt, optionsof.txt,
|
||||||
|
* servers.dat, usercache.json 등 최상위 파일 전부)을 .mc_custom 으로 복사한다.
|
||||||
|
* 이미 .mc_custom 에 같은 이름의 파일이 있으면 보존(덮어쓰지 않음).
|
||||||
|
* 디렉터리(mods/saves/versions/assets 등)는 각자 별도 처리하므로 여기서는 건드리지 않는다.
|
||||||
|
*/
|
||||||
|
async function copyMinecraftUserSettings(customRoot: string): Promise<void> {
|
||||||
|
const mcRoot = path.join(getAppDataDir(), '.minecraft')
|
||||||
|
if (!fs.existsSync(mcRoot)) {
|
||||||
|
sendLog('.minecraft 폴더가 없어 기존 설정 복사를 건너뜁니다.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let copied = 0
|
||||||
|
let skipped = 0
|
||||||
|
try {
|
||||||
|
const entries = await fsp.readdir(mcRoot, { withFileTypes: true })
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (!entry.isFile()) continue
|
||||||
|
const src = path.join(mcRoot, entry.name)
|
||||||
|
const dst = path.join(customRoot, entry.name)
|
||||||
|
if (fs.existsSync(dst)) {
|
||||||
|
skipped += 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await fsp.copyFile(src, dst)
|
||||||
|
copied += 1
|
||||||
|
} catch (err) {
|
||||||
|
sendLog(`설정 복사 실패 (${entry.name}): ${(err as Error).message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendLog(`기존 마인크래프트 설정 복사: 새로 복사 ${copied}개 / 보존(이미 존재) ${skipped}개.`)
|
||||||
|
} catch (err) {
|
||||||
|
sendLog(`기존 설정 복사 중 오류: ${(err as Error).message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .mc_custom 에서 마인크래프트 런처가 찾는 assets/libraries/versions 를
|
* .mc_custom 에서 마인크래프트 런처가 찾는 assets/libraries/versions 를
|
||||||
* .minecraft 의 같은 폴더로 junction(Windows) / symlink(POSIX) 한다.
|
* .minecraft 의 같은 폴더로 junction(Windows) / symlink(POSIX) 한다.
|
||||||
|
|||||||
Reference in New Issue
Block a user