-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- installer now also updates clouds, render distance, chat height and volumes - added dedicated `options.txt` parser - added legacy minecraft installation path - logs now include installer version - split files in `src/providers/` into dedicated files for each function
- Loading branch information
Showing
13 changed files
with
146 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { storeToRefs } from 'pinia'; | ||
import { useInstallerStore } from 'src/stores/InstallerStore'; | ||
import { useSourcesStore } from 'src/stores/SourcesStore'; | ||
import { useStateStore } from 'src/stores/StateStore'; | ||
import { Ref } from 'vue'; | ||
import { downloadFile } from './DownloadFile'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
export async function downloadMods(ref: Ref) { | ||
const startTime = Date.now(); | ||
|
||
const { launcher } = storeToRefs(useSourcesStore()); | ||
const { minecraftDir } = storeToRefs(useInstallerStore()); | ||
const { processingMods } = storeToRefs(useStateStore()); | ||
|
||
const modList = launcher.value.modList; | ||
const modLoader = launcher.value.fabric.name; | ||
const totalMods = modList.length; | ||
let downloaded = 0; | ||
|
||
const modsPath = path.join(minecraftDir.value, 'mods'); | ||
if (!fs.existsSync(modsPath)) fs.mkdirSync(modsPath, { recursive: true }); | ||
|
||
async function processArray(mods: typeof modList): Promise<void> { | ||
for (const mod of mods) { | ||
const { name, mod_version, mc_version, source } = mod; | ||
const modName = | ||
name + ' - ' + modLoader + mod_version + '-' + mc_version + '.jar'; | ||
console.log(`Downloading ${modName} to ${modsPath}`); | ||
const modPath = path.join(modsPath, modName); | ||
await downloadFile(source, modPath); | ||
downloaded++; | ||
const progress = downloaded / totalMods; | ||
const percent = (progress * 100).toFixed(1); | ||
|
||
ref.value.progress = progress; | ||
ref.value.percent = percent; | ||
// Note: Roughly 21 character limit, consider truncating mod name | ||
ref.value.label = `Downloading: ${name}`; | ||
|
||
const taken = Date.now() - startTime; | ||
console.log(`downloaded mod ${downloaded}/${totalMods} in ${taken}ms`); | ||
} | ||
} | ||
await processArray(modList); | ||
ref.value.label = 'Mods successfully downloaded!'; | ||
ref.value.img = | ||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAACqElEQVRYhdVYzY7SUBT+Tu1CTWRaG4UncKMOxOWMhhg37khYwBgT43P4ADyIiSawMLBzA0LUWRLGv4VPwMwECjVhiJYeF6W1pTBD7+2Mw7e67b0993733HvOd0r1ahuFUh6NWoexgSiU8tSodUDMjEatw0QETb/2v9cVCyPzBMyMQilPVK+2GQAUhbClbRaR8egEjuMeJBUA9JvX/U7DSElP8OJp59T+1+/z0nMMBpa/8eZw4hLx4JG4mlKjX8ZALqOv7Ov1TWn7U8uGYaQwGFj+u4hFkUnKO02/zQBq+09OHb+324LDDFpz/LI1Ti079E4FxbKxFPfSGq6Qa+jn8NeZ47fTmt/u9U35BRCgkgST8m4TzPF39NW7B6HnZw9bmDkc244HAqC4zhVDNq1DIXmX3r+tQVXk7Ciyi0jgZCYCKSIOMxTJnfRAkp4VioOVYhffjsZ4++mx0KSlQJQjANX53agUu+j1TaG7IhzQbccR/TSUZw4OE4haIHEiIijvtsDMyGV0KY9GwRdLJBvIHw4nK7YTIbI332lvaYtnPOiJ78djvPmYlCf+IREiwUz95XAU6c+mNZ/kzDmfsicRIl6mrhS72E5roagEuES/Ho1Q/SyWudeBMBFVWZ2CglGJ4YZYGSm0DqhebbNXjxhGKpb6fZnvYPLHjtyJSrHrtw/6pp8nVqG00wQRYnlsatm+jDeHE7nMfse4kYjWymV0Xz2L4lzC76K6vQjIi8ZLohqlPOLtvFeXeDhLKy1GNdE6JIhEjlY2HdBOa1R8yWutJUSmlh27bl+8E88ffcDM4YgMUYjgsHglGFzjIkIrHgwsGEZq6cA4uHtra+n737MZfhxb0vYBhP6gAPM84j0E/29tAszhxG8ruDzVqgzIO1oEgIMMNwgEAH8Bhif2yStQayoAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg=='; | ||
processingMods.value = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { storeToRefs } from 'pinia'; | ||
import { useInstallerStore } from 'src/stores/InstallerStore'; | ||
import { useSourcesStore } from 'src/stores/SourcesStore'; | ||
import { useStateStore } from 'src/stores/StateStore'; | ||
import { Ref } from 'vue'; | ||
import { downloadFile } from './DownloadFile'; | ||
import { updateMinecraftOpts } from './UpdateMinecraftOpts'; | ||
const path = require('path'); | ||
|
||
export async function downloadResourcePack(ref: Ref) { | ||
const { resourcePack } = storeToRefs(useSourcesStore()); | ||
const { minecraftDir } = storeToRefs(useInstallerStore()); | ||
const { processingResourcepack } = storeToRefs(useStateStore()); | ||
ref.value.label = 'Downloading resource pack'; | ||
|
||
// NOTE: if changing this, edit the value in src/providers/UpdateMinecraftOpts.ts | ||
const rpName = `Drehmal Resource Pack v${resourcePack.value.version}.zip`; | ||
const filePath = path.join(minecraftDir.value, 'resourcepacks', rpName); | ||
console.log(`Downloading resource pack to: ${filePath}`); | ||
downloadFile(resourcePack.value.source, filePath, ref).then(() => { | ||
ref.value.label = 'Updating video settings'; | ||
|
||
const optionsFilePath = path.join(minecraftDir.value, 'options.txt'); | ||
|
||
console.log(`Updating Minecraft options in file: ${optionsFilePath}`); | ||
updateMinecraftOpts(optionsFilePath); | ||
|
||
ref.value.label = 'Resource pack downloaded!'; | ||
|
||
console.log('Updated Resource Pack order and video settings'); | ||
processingResourcepack.value = false; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { storeToRefs } from 'pinia'; | ||
import { useSourcesStore } from 'src/stores/SourcesStore'; | ||
|
||
const fs = require('fs'); | ||
|
||
export function updateMinecraftOpts(filename: string) { | ||
// Parse options file into an array of strings for each line | ||
const lines: string[] = fs.readFileSync(filename, 'utf-8').split('\n'); | ||
// Create object to store the options as a json object for easy access | ||
const options: Record<string, string> = {}; | ||
// add each option to the created object | ||
lines.forEach((line) => { | ||
const [key, value] = line.split(':'); | ||
if (key && value) { | ||
options[key.trim()] = value.trim(); | ||
} | ||
}); | ||
|
||
const { resourcePack } = storeToRefs(useSourcesStore()); | ||
const rpName = `Drehmal Resource Pack v${resourcePack.value.version}.zip`; | ||
|
||
// modify options here | ||
// update resource pack order to include Drehmal's pack at the top | ||
options['resourcePacks'] = `["vanilla","Fabric Mods","file/${rpName}"]`; | ||
// disable clouds, gets in the way of towers/structures | ||
options['renderClouds'] = 'false'; | ||
// increase render distance to required minimum (consider scale based on memory allocation) | ||
if (parseInt(options['renderDistance']) < 8) options['renderDistance'] = '8'; | ||
// maximise unfocused chat size so players can properly use menus | ||
options['chatHeightUnfocused'] = '1.0'; | ||
// ensure custom music is enabled | ||
options['soundCategory_music'] = '1.0'; | ||
options['soundCategory_record'] = '1.0'; | ||
|
||
let newOptions = ''; | ||
Object.keys(options).forEach( | ||
(key) => (newOptions += `${key}:${options[key]}\n`) | ||
); | ||
|
||
fs.writeFileSync(filename, newOptions); | ||
} |