UPDATE: Add ldiff

This commit is contained in:
2025-08-25 18:12:13 +07:00
parent 99b9df1ce5
commit 6b222bfa70
45 changed files with 1700 additions and 535 deletions

View File

@@ -2,11 +2,12 @@ import useSettingStore from "@/stores/settingStore"
import { Check, Folder, File, X, Settings } from "lucide-react"
import { useEffect } from "react"
import { toast } from "react-toastify"
import { FSService, HdiffzService} from "@bindings/firefly-launcher/internal"
import { DiffService} from "@bindings/firefly-launcher/internal/diff-service"
import { FSService } from "@bindings/firefly-launcher/internal/fs-service"
import { motion } from "motion/react"
import useHdiffzStore from "@/stores/hdiffzStore"
import useDiffStore from "@/stores/diffStore"
export default function HdiffzPage() {
export default function DiffPage() {
const { gameDir, setGameDir } = useSettingStore()
const {
isLoading,
@@ -27,7 +28,7 @@ export default function HdiffzPage() {
setStageType,
messageUpdate,
setMessageUpdate
} = useHdiffzStore()
} = useDiffStore()
useEffect(() => {
const getLanguage = async () => {
@@ -78,7 +79,7 @@ export default function HdiffzPage() {
const handlePickDiffFile = async () => {
try {
setIsLoading({game: false, diff: true})
const basePath = await FSService.PickFile()
const basePath = await FSService.PickFile("")
if (basePath) {
if (!basePath.endsWith(".7z") && !basePath.endsWith(".zip") && !basePath.endsWith(".rar")) {
toast.error('Not valid file type')
@@ -86,9 +87,15 @@ export default function HdiffzPage() {
setDiffDir('')
return
}
const [exists, error] = await FSService.FileExistsInZip(basePath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes")
if (!exists) {
toast.error(error)
const [isOk, validType, errorType] = await DiffService.CheckTypeHDiff(basePath)
if (!isOk) {
toast.error(errorType)
setDiffCheckResult('error')
setDiffDir('')
return
}
if (validType == "") {
toast.error('Not valid file type')
setDiffCheckResult('error')
setDiffDir('')
return
@@ -119,7 +126,7 @@ export default function HdiffzPage() {
setStageType('Check Type HDiff')
setProgressUpdate(0)
setMaxProgressUpdate(1)
const [isOk, validType, errorType] = await HdiffzService.CheckTypeHDiff(diffDir)
const [isOk, validType, errorType] = await DiffService.CheckTypeHDiff(diffDir)
if (!isOk) {
toast.error(errorType)
setIsDiffLoading(false)
@@ -127,11 +134,13 @@ export default function HdiffzPage() {
}
setProgressUpdate(1)
if (validType === 'hdiffmap.json') {
setStageType('Version Validate')
setProgressUpdate(0)
setMaxProgressUpdate(1)
const [validVersion, errorVersion] = await HdiffzService.VersionValidate(gameDir, diffDir)
const [validVersion, errorVersion] = await DiffService.VersionValidate(gameDir, diffDir)
if (!validVersion) {
toast.error(errorVersion)
setIsDiffLoading(false)
@@ -140,8 +149,9 @@ export default function HdiffzPage() {
setProgressUpdate(1)
}
const isSkipVerify = validType === 'manifest' || validType === 'hdifffiles.txt'
setStageType('Data Extract')
const [validData, errorData] = await HdiffzService.DataExtract(gameDir, diffDir, validType === 'hdifffiles.txt')
const [validData, errorData] = await DiffService.DataExtract(gameDir, diffDir, isSkipVerify)
if (!validData) {
toast.error(errorData)
setIsDiffLoading(false)
@@ -150,28 +160,38 @@ export default function HdiffzPage() {
setStageType('Cut Data')
setMessageUpdate('')
const [validCut, errorCut] = await HdiffzService.CutData(gameDir)
const [validCut, errorCut] = await DiffService.CutData(gameDir)
if (!validCut) {
toast.error(errorCut)
setIsDiffLoading(false)
return
}
setStageType('Patch Data')
const [validPatch, errorPatch] = await HdiffzService.PatchData(gameDir)
if (!validPatch) {
toast.error(errorPatch)
setIsDiffLoading(false)
return
if ( validType === 'hdifffiles.txt' || validType === 'hdiffmap.json') {
setStageType('Patch Data')
const [validPatch, errorPatch] = await DiffService.HDiffPatchData(gameDir)
if (!validPatch) {
toast.error(errorPatch)
setIsDiffLoading(false)
return
}
setStageType('Delete old files')
const [validDelete, errorDelete] = await DiffService.DeleteFiles(gameDir)
if (!validDelete) {
toast.error(errorDelete)
setIsDiffLoading(false)
return
}
} else if (validType === 'manifest') {
setStageType('Patch Data')
const [validPatch, errorPatch] = await DiffService.LDiffPatchData(gameDir)
if (!validPatch) {
toast.error(errorPatch)
setIsDiffLoading(false)
return
}
}
setStageType('Delete old files')
const [validDelete, errorDelete] = await HdiffzService.DeleteFiles(gameDir)
if (!validDelete) {
toast.error(errorDelete)
setIsDiffLoading(false)
return
}
toast.success('Update game completed')
} catch (err: any) {
console.error(err)

View File

@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { Folder, Settings, Check, X, Globe, Mic } from 'lucide-react'
import { FSService } from '@bindings/firefly-launcher/internal'
import { LanguageService } from '@bindings/firefly-launcher/internal'
import { FSService } from '@bindings/firefly-launcher/internal/fs-service'
import { LanguageService } from '@bindings/firefly-launcher/internal/language-service'
import { toast } from 'react-toastify'
import useSettingStore from '@/stores/settingStore'

View File

@@ -1,6 +1,7 @@
import { useEffect } from 'react';
import { Play, Menu, FolderOpen, MessageCircleQuestionMark } from 'lucide-react';
import { FSService, AppService } from '@bindings/firefly-launcher/internal';
import { AppService } from '@bindings/firefly-launcher/internal/app-service';
import { FSService } from '@bindings/firefly-launcher/internal/fs-service';
import { toast } from 'react-toastify';
import path from 'path-browserify'
import useSettingStore from '@/stores/settingStore';
@@ -120,7 +121,7 @@ export default function LauncherPage() {
const handlePickFile = async () => {
try {
setIsLoading(true)
const basePath = await FSService.PickFile()
const basePath = await FSService.PickFile("exe")
if (basePath.endsWith("StarRail.exe") || basePath.endsWith("launcher.exe")) {
const normalized = basePath.replace(/\\/g, '/')
const folderPath = path.dirname(normalized)