Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrin committed Sep 28, 2023
1 parent 20fcb76 commit 51f680a
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 2 deletions.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# DivaAutoBackup
Alternative executable file for Diva MegaMix+ that automatically backs up your modded offline save file
# divaAutoBackup

**NECESSARY DEPENDENCY PLEASE INSTALL!!!**

7-Zip needs to be installed for this to work!
Directly download it from here if you don't have it:
https://www.7-zip.org/a/7z2201-x64.exe

**What is this?**

divaAutoBackup or DivaAB or DAB (hahah) or whatever you want to call it is a alternative launcher
(EXE file) for the PC game 'Hatsune Miku: Project DIVA MegaMix+'.

The game natively supports Steam cloud save, but, if you add lots mods to the game, for example,
a bunch of song packs and module packs, the cloud save function will stop working, and the modloader
will create it's own offline save file, on a separate folder inside %AppData%\Roaming.

I format my PC a lot, and 3 or 4 times now I completely lost my progress in the game because it was
using this offline save due to mods, and I forgot to back it up, so I made this.

The .exe file was made using the ps2exe powershell module.

**How does it work?**

The script uses steam to launch the game through it's AppID, once the game is launched, the program
will check if it is still running every second. If it is, it does nothing, if you close the game
and it detects that it's closed, it creates a backup of your save inside your Documents folder in a
folder called "DivaBackups". If you have some sort of cloud backup going on like GoogleDrive or
OneDrive, it's gonna pick it up and cloud save it for you, problem solved (i hope).

**How do I use it?**

Download the latest .exe file from releases, place it wherever you want and run it.
101 changes: 101 additions & 0 deletions script.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Clear garbage
Clear-Host

# Username crap
$username = $env:USERNAME
$profilePath = (Get-ChildItem "C:\Users\" -Filter $username).FullName

# Paths
$documentsPath = [Environment]::GetFolderPath('MyDocuments')
$savePath = $profilePath + '\AppData\Roaming\DIVA'
$segaPath = $profilePath + '\AppData\Roaming\SEGA'
$backPath = $documentsPath + '\DivaBackups'
$steamPath = "C:\Program Files (x86)\Steam\steam.exe"

# Game properties
$gameId = "1761390"
$gameExe = "DivaMegaMix"

# Filename
$datetime = get-date -Format "dd.MM.yy-HHmm"
$filename = "DIVA_" + $datetime + ".7z"

# For script shenanigans
$trackingMessageDisplayed = 0
$sevenZipUrl = "https://www.7-zip.org/"

# Message
Write-Output " _____ _ _ ____ _ "
Write-Output " | __ \(_) /\ | | | _ \ | | "
Write-Output " | | | |___ ____ _ / \ _ _| |_ ___ | |_) | __ _ ___| | ___ _ _ __ "
Write-Output " | | | | \ \ / / _\` | / /\ \| | | | __/ _ \ | _ < / _\` |/ __| |/ / | | | '_ \ "
Write-Output " | |__| | |\ V / (_| | / ____ \ |_| | || (_) | | |_) | (_| | (__| <| |_| | |_) |"
Write-Output " |_____/|_| \_/ \__,_| /_/ \_\__,_|\__\___/ |____/ \__,_|\___|_|\_\\__,_| .__/ "
Write-Output " | | "
Write-Output " |_| "
Write-Output " v1.0.1 by rin "

# Launch DIVA
Write-Host "Starting DIVA..."
Start-Process -FilePath $steamPath -ArgumentList "-applaunch $gameId"

# Try to find DIVA process
Write-Host "Looking for DIVA..."
do{
$gameProcess = Get-Process | Where-Object {$_.ProcessName -eq $gameExe}
}until($null -ne $gameProcess)

# Track DIVA every second until it closes
do{
if($trackingMessageDisplayed -eq 0){
Write-Host "Tracking DIVA..."
$trackingMessageDisplayed = 1
}
Start-Sleep -Milliseconds 1000
}until($gameProcess.HasExited)

# Make sure process is null after DIVA closes
$gameProcess = Get-Process | Where-Object {$_.ProcessName -eq $gameExe}

function exitMessage{
Write-Output " "
Write-Output "Thank you for using DivaAutoBackup."
Start-Sleep -Seconds 5
exit
}

function doBackup{
# Anti-dummy
if((Test-Path $segaPath) -and (Test-Path $savePath)){
Write-Host "Creating offline save backup..."
}elseif(Test-Path $segaPath){
$savePath = $segaPath
Write-Host "Offline save not found. Backing up default SEGA folder instead."
}else{
Write-Host "No saves where found. Exiting."
exitMessage
}

# Anti-dummy 2
if(Test-Path "C:\Program Files\7-Zip"){
# Do backup
C:\'Program Files'\7-Zip\7z.exe -bso0 a temp.7z $savePath
Rename-Item temp.7z $filename
Move-Item *.7z $backPath
exitMessage
}else{
Write-Host "You don't have 7-Zip. Install it for divaAutoBackup to work."
Start-Process $sevenZipUrl
exitMessage
}
}

# Backup save
if($null -eq $gameProcess){
if(Test-Path $backPath){
doBackup
}else{
New-Item -ItemType Directory -Path $backPath
doBackup
}
}

0 comments on commit 51f680a

Please sign in to comment.