Skip to content

Commit 01b78be

Browse files
committed
#skip-ci v0.0.7 beta candidate
- 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
1 parent 80a0802 commit 01b78be

13 files changed

+146
-119
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drehmal-installer",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Drehmal, Minecraft map installer",
55
"productName": "Drehmal Installer",
66
"author": "majorlue",

src-electron/electron-main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const path = require('path');
66
const os = require('os');
77
const fs = require('fs');
88

9+
import { version } from '../package.json';
10+
911
// Optional, initialize the logger for any renderer process
1012
log.initialize({ spyRendererConsole: true });
1113
const currDate = dayjs().format('DD-MM-YYYY');
@@ -34,7 +36,7 @@ log.transports.file.format = '[{h}:{i}:{s}.{ms}] [{level}] {text}';
3436
log.errorHandler.startCatching();
3537
log.eventLogger.startLogging();
3638

37-
log.info('Logger initialised');
39+
log.info(`Installer v${version}: Logger initialised`);
3840

3941
let mainWindow: BrowserWindow | undefined;
4042

@@ -46,6 +48,7 @@ function createWindow() {
4648
icon: path.resolve(__dirname, 'icons/icon.png'), // tray icon
4749
width: 1000,
4850
height: 600,
51+
resizable: false,
4952
useContentSize: true,
5053
webPreferences: {
5154
nodeIntegration: true,

src/components/CloseInstaller.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const launchButton = ref(false);
2727
const platform: Ref<NodeJS.Platform | undefined> = ref();
2828
2929
const windowsLocations: string[] = [
30+
// Microsoft Store install location
3031
'C:\\XboxGames\\Minecraft Launcher\\Content\\Minecraft.exe',
32+
// Legacy install location
33+
'C:\\Program Files (x86)\\Minecraft',
3134
];
3235
let windowsPath = '';
3336

src/components/MultiplayerInstall.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
import { storeToRefs } from 'pinia';
3535
import ProgressBox from 'src/components/ProgressBox.vue';
3636
import { ProgressBox as ProgressBoxType, Shard } from 'src/components/models';
37-
import {
38-
downloadMods,
39-
downloadResourcePack,
40-
installFabric,
41-
} from 'src/providers/InstallFabric';
37+
import { downloadMods } from 'src/providers/DownloadMods';
38+
import { downloadResourcePack } from 'src/providers/DownloadResourcePack';
39+
import { installFabric } from 'src/providers/InstallFabric';
4240
import { useSourcesStore } from 'src/stores/SourcesStore';
4341
import { useStateStore } from 'src/stores/StateStore';
4442
import { ref } from 'vue';

src/components/SingleplayerInstall.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ import {
5858
Shard,
5959
ShardsBox,
6060
} from 'src/components/models';
61+
import { downloadMods } from 'src/providers/DownloadMods';
62+
import { downloadResourcePack } from 'src/providers/DownloadResourcePack';
6163
import { downloadShards } from 'src/providers/DownloadShards';
62-
import {
63-
downloadMods,
64-
downloadResourcePack,
65-
installFabric,
66-
} from 'src/providers/InstallFabric';
64+
import { installFabric } from 'src/providers/InstallFabric';
6765
import { useInstallerStore } from 'src/stores/InstallerStore';
6866
import { useSourcesStore } from 'src/stores/SourcesStore';
6967
import { useStateStore } from 'src/stores/StateStore';

src/components/SocialsGrid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const socials: Ref<Socials[]> = ref([
3232
img: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAACIUlEQVRYhe2YwW7aQBCGvzGWmuYApqghrxCllKrHphJS+gBIPRDlVfoAeZXIHCp4gCKQmh6rpnmJUInY4ZDkkLA9IFs23kC8No2R+p2s3Vl7fs94Zr3Sc4e0Oy363ZFiA2l3WtLv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uwu7FxYz8VA9SBZA+oj/ODk7vl34xbsHdS9/UojtD+druJEXjGin3c0afES7XiL7X3IEFezsNfjMDREDfjPp7VrRJEAENAnpdbbc3tD7IuPAkD9C7y8VgrlIdUeTPGCm0Rhx+A5CoA5I6co+b67cuHHsK9IsoqlJGFBer0q4lzUxeRCYLZkKQykjyW7iKyDTSYrbiuh4HCcLjoMP+BCA434oHVB2hGwimlo5zlLIhsdgJAMcd1ggCgG++oJDts2wnOwAAAABJRU5ErkJggg==',
35-
url: 'https://discord.com/invite/n6VVwDFp?utm_source=Discord%20Widget&utm_medium=Connect',
35+
url: 'https://discord.gg/xFsRQsDnuj',
3636
},
3737
{
3838
name: 'website',

src/providers/DownloadFile.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const fs = require('fs');
33
import { Ref } from 'vue';
44
const path = require('path');
55

6-
function downloadFile(url: string, savePath: string, ref?: Ref): Promise<void> {
6+
export function downloadFile(
7+
url: string,
8+
savePath: string,
9+
ref?: Ref
10+
): Promise<void> {
711
return new Promise((resolve, reject) => {
812
const name = savePath.split(path.sep).pop();
913
const file = fs.createWriteStream(savePath);
@@ -71,5 +75,3 @@ function downloadFile(url: string, savePath: string, ref?: Ref): Promise<void> {
7175
});
7276
});
7377
}
74-
75-
export { downloadFile };

src/providers/DownloadMods.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { storeToRefs } from 'pinia';
2+
import { useInstallerStore } from 'src/stores/InstallerStore';
3+
import { useSourcesStore } from 'src/stores/SourcesStore';
4+
import { useStateStore } from 'src/stores/StateStore';
5+
import { Ref } from 'vue';
6+
import { downloadFile } from './DownloadFile';
7+
const fs = require('fs');
8+
const path = require('path');
9+
10+
export async function downloadMods(ref: Ref) {
11+
const startTime = Date.now();
12+
13+
const { launcher } = storeToRefs(useSourcesStore());
14+
const { minecraftDir } = storeToRefs(useInstallerStore());
15+
const { processingMods } = storeToRefs(useStateStore());
16+
17+
const modList = launcher.value.modList;
18+
const modLoader = launcher.value.fabric.name;
19+
const totalMods = modList.length;
20+
let downloaded = 0;
21+
22+
const modsPath = path.join(minecraftDir.value, 'mods');
23+
if (!fs.existsSync(modsPath)) fs.mkdirSync(modsPath, { recursive: true });
24+
25+
async function processArray(mods: typeof modList): Promise<void> {
26+
for (const mod of mods) {
27+
const { name, mod_version, mc_version, source } = mod;
28+
const modName =
29+
name + ' - ' + modLoader + mod_version + '-' + mc_version + '.jar';
30+
console.log(`Downloading ${modName} to ${modsPath}`);
31+
const modPath = path.join(modsPath, modName);
32+
await downloadFile(source, modPath);
33+
downloaded++;
34+
const progress = downloaded / totalMods;
35+
const percent = (progress * 100).toFixed(1);
36+
37+
ref.value.progress = progress;
38+
ref.value.percent = percent;
39+
// Note: Roughly 21 character limit, consider truncating mod name
40+
ref.value.label = `Downloading: ${name}`;
41+
42+
const taken = Date.now() - startTime;
43+
console.log(`downloaded mod ${downloaded}/${totalMods} in ${taken}ms`);
44+
}
45+
}
46+
await processArray(modList);
47+
ref.value.label = 'Mods successfully downloaded!';
48+
ref.value.img =
49+
'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==';
50+
processingMods.value = false;
51+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { storeToRefs } from 'pinia';
2+
import { useInstallerStore } from 'src/stores/InstallerStore';
3+
import { useSourcesStore } from 'src/stores/SourcesStore';
4+
import { useStateStore } from 'src/stores/StateStore';
5+
import { Ref } from 'vue';
6+
import { downloadFile } from './DownloadFile';
7+
import { updateMinecraftOpts } from './UpdateMinecraftOpts';
8+
const path = require('path');
9+
10+
export async function downloadResourcePack(ref: Ref) {
11+
const { resourcePack } = storeToRefs(useSourcesStore());
12+
const { minecraftDir } = storeToRefs(useInstallerStore());
13+
const { processingResourcepack } = storeToRefs(useStateStore());
14+
ref.value.label = 'Downloading resource pack';
15+
16+
// NOTE: if changing this, edit the value in src/providers/UpdateMinecraftOpts.ts
17+
const rpName = `Drehmal Resource Pack v${resourcePack.value.version}.zip`;
18+
const filePath = path.join(minecraftDir.value, 'resourcepacks', rpName);
19+
console.log(`Downloading resource pack to: ${filePath}`);
20+
downloadFile(resourcePack.value.source, filePath, ref).then(() => {
21+
ref.value.label = 'Updating video settings';
22+
23+
const optionsFilePath = path.join(minecraftDir.value, 'options.txt');
24+
25+
console.log(`Updating Minecraft options in file: ${optionsFilePath}`);
26+
updateMinecraftOpts(optionsFilePath);
27+
28+
ref.value.label = 'Resource pack downloaded!';
29+
30+
console.log('Updated Resource Pack order and video settings');
31+
processingResourcepack.value = false;
32+
});
33+
}

src/providers/DownloadShards.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ShardsBox } from 'src/components/models';
44
import { Ref } from 'vue';
55
const path = require('path');
66

7-
function downloadShards(
7+
export function downloadShards(
88
url: string,
99
savePath: string,
1010
ref: Ref<ShardsBox>
@@ -74,5 +74,3 @@ function downloadShards(
7474
});
7575
});
7676
}
77-
78-
export { downloadShards };

0 commit comments

Comments
 (0)