Skip to content

Commit

Permalink
v0.0.5 fully implemented all 3 installation types, switched map sourc…
Browse files Browse the repository at this point in the history
…es to .zip files, launches minecraft on exit

- updated install page to be dynamic per installation type
- added unique configuration pages for each install type
- removed placeholder text
- `.tar.gz` files may unfortunately incompatible with minecraft's internals
- added function provider for `.zip` file extraction
- removed tar-gz package, added unzip package
  • Loading branch information
jgaribsin committed Jan 8, 2024
1 parent 47cfe5a commit 79c568b
Show file tree
Hide file tree
Showing 26 changed files with 1,021 additions and 483 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Drehmal, Minecraft map installer. The idea is to install everything needed for D
- ❌ Test on MacOs
- ✅ Test on Windows
- ❌ Create backend server pointing to up to date resources
- Refactor large components (eg. `components/MapDownload.vue`) into multiple smaller ones
- Refactor large components (eg. `components/MapDownload.vue`) into multiple smaller ones
- ✅ Set Drehmal Resource Pack as active
- ✅ Cleanup installation files (fabric launcher, map tarball)
- ❌ Improve application logging
- ❌ App-wide error catching and handling
- ❌ Recovery states on errors
- ✅ Singleplayer functionality (map, resource pack, mods)
- ✅ Multiplayer client functionality (resource pack, mods)
- Multiplayer host functionality (map, server jar)
- Multiplayer host functionality (map, server jar)

## Known Issues

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drehmal-installer",
"version": "0.0.4",
"version": "0.0.5",
"description": "Drehmal, Minecraft map installer",
"productName": "Drehmal Installer",
"author": "majorlue",
Expand All @@ -25,9 +25,9 @@
"axios": "^1.2.1",
"dayjs": "^1.11.10",
"electron-log": "^5.0.3",
"extract-zip": "^2.0.1",
"pinia": "^2.0.11",
"quasar": "^2.14.2",
"tar-pack": "^3.4.1",
"vue": "^3.0.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.0"
Expand All @@ -53,4 +53,4 @@
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
}
}
}
4 changes: 4 additions & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Drehmal*
map
parts
archive
46 changes: 46 additions & 0 deletions scripts/split.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import shutil
import zipfile

def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size # size in bytes

def split_directory(path, max_size, output_path):
current_size = 0
current_dir = os.path.join(output_path, 'subdir_1')
os.makedirs(current_dir, exist_ok=True)
dir_counter = 1

for foldername, subfolders, filenames in os.walk(path):
for filename in filenames:
file_path = os.path.join(foldername, filename)
file_size = os.path.getsize(file_path)
if current_size + file_size > max_size:
# Zip the current directory
with zipfile.ZipFile(f'{current_dir}.zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
for folder, subfolders, files in os.walk(current_dir):
for file in files:
zipf.write(os.path.join(folder, file),
os.path.relpath(os.path.join(folder, file), current_dir))
shutil.rmtree(current_dir)

# Start a new directory
dir_counter += 1
current_dir = os.path.join(output_path, f'subdir_{dir_counter}')
os.makedirs(current_dir, exist_ok=True)
current_size = 0

# Copy the file to the new directory
rel_path = os.path.relpath(foldername, path)
new_folder = os.path.join(current_dir, rel_path)
os.makedirs(new_folder, exist_ok=True)
shutil.copy(file_path, new_folder)
current_size += file_size

# Usage
split_directory('./map', 500*1024*1024, './parts')
8 changes: 3 additions & 5 deletions src-electron/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import {
app as ElectronApp,
shell as ElectronShell,
} from 'electron';
const path = require('path');
const { execFile, spawn } = require('child_process');
import log from 'electron-log';
// import path from 'path';
// log.info('IPC Listener');
const { spawn } = require('child_process');

let browserWindow: BrowserWindow;
let app: typeof ElectronApp;
let shell: typeof ElectronShell;
Expand All @@ -27,6 +24,7 @@ export default class Listeners {

ipcMain.handle('getAppPath', () => app.getAppPath());
ipcMain.handle('getAppDataPath', () => app.getPath('appData'));
ipcMain.handle('getDesktopPath', () => app.getPath('desktop'));
ipcMain.handle('openInBrowser', (_event, url) => shell.openExternal(url));
ipcMain.handle('quit', () => app.quit());
ipcMain.handle('getPlatform', () => process.platform);
Expand Down
13 changes: 8 additions & 5 deletions src/components/CloseInstaller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ const click = () => {
log.info(
`Launching Minecraft on ${platform.value} with file: ${windowsPath}`
);
ipcRenderer.invoke('minecraftWin', windowsPath);
ipcRenderer.invoke('minecraftWin', windowsPath).then(() => {
log.info('Minecraft launched, exiting...');
ipcRenderer.invoke('quit');
});
} else {
log.info(
`Launching Minecraft on ${platform.value} with cmd: minecraft-launcher`
);
ipcRenderer.invoke('minecraftNotWin');
ipcRenderer.invoke('minecraftNotWin').then(() => {
log.info('Minecraft launched, exiting...');
ipcRenderer.invoke('quit');
});
}
}
log.info('Exiting launcher...');
ipcRenderer.invoke('quit');
};
</script>
58 changes: 32 additions & 26 deletions src/components/MemorySelect.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<template>
<div class="ram-select white">
<span
>Ram Allocation: <span class="custom">{{ memory }}GB</span> (Max
{{ maxMem }}GB)</span
>
<span></span>
<q-slider
v-model="memory"
:min="minMem"
:max="maxMem"
:step="step"
label
snap
color="accent"
/>
<div style="padding-bottom: 10px">
<q-item-section>
<q-item-label>
Ram Allocation: <span class="custom">{{ memory }}GB</span> (Min:
{{ minMem }}GB / Max {{ maxMem }}GB)
</q-item-label>
</q-item-section>
</div>
<div>
<q-slider
v-model="memory"
:min="minMem"
:max="maxMem"
:step="step"
label
snap
color="accent"
/>
</div>
</div>
</template>

Expand All @@ -27,21 +32,22 @@ const { memory } = storeToRefs(useInstallerStore());
const minMem = 4;
const memoryInGB = os.totalmem() / Math.pow(1024, 3);
const maxMem = Math.round((memoryInGB * 0.75) / 0.5 - 1) * 0.5;
const recommendedMem = minMem + (maxMem - minMem) / 2;
memory.value = recommendedMem;
const step = 0.5;
</script>
<style scoped>
.ram-select {
padding: 1rem;
<style scoped lang="sass">
.ram-select
padding: 1rem
background-color: #7e57c2;
background-color: #7e57c2
border-radius: 0.3rem;
border-radius: 0.3rem
text-align: center;
font-weight: bold;
line-height: 48px;
width: 60%;
height: 96px;
max-height: 96px;
}
text-align: center
font-weight: bold
line-height: 48px
width: 60%
height: 96px
max-height: 96px
</style>
146 changes: 146 additions & 0 deletions src/components/MultiplayerInstall.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<template>
<div class="">
<!-- Fabric download, install -->
<progress-box
:label="fabricProgress.label"
:progress="fabricProgress.progress"
:percent="fabricProgress.percent"
:img="fabricProgress.img"
:buttonClick="fabricClick"
:buttonDisabled="fabricDisabled"
/>
<!-- Mods download -->
<progress-box
:label="modsProgress.label"
:progress="modsProgress.progress"
:percent="modsProgress.percent"
:img="modsProgress.img"
:buttonClick="modsClick"
:buttonDisabled="modsDisabled"
/>
<!-- Resource Pack download -->
<progress-box
:label="resourcepackProgress.label"
:progress="resourcepackProgress.progress"
:percent="resourcepackProgress.percent"
:img="resourcepackProgress.img"
:buttonClick="resourcepackClick"
:buttonDisabled="resourcepackDisabled"
/>
</div>
</template>

<script setup lang="ts">
import { storeToRefs } from 'pinia';
import ProgressBox from 'src/components/ProgressBox.vue';
import { ProgressBox as ProgressBoxType, Shard } from 'src/components/models';
import {
downloadMods,
downloadResourcePack,
installFabric,
} from 'src/providers/InstallFabric';
import { useSourcesStore } from 'src/stores/SourcesStore';
import { useStateStore } from 'src/stores/StateStore';
import { ref } from 'vue';
const { map } = storeToRefs(useSourcesStore());
const {
processingFabric,
processingMods,
processingResourcepack,
disableBackNav,
} = storeToRefs(useStateStore());
const versionFileName = map.value.versionName
.toLowerCase()
.split(' ')
.join('-');
const shardsArr: Shard[] = [];
const fabricDisabled = ref(false);
const modsDisabled = ref(false);
const resourcepackDisabled = ref(false);
map.value.shards.forEach((shard, i) =>
shardsArr.push({
index: i,
name: `${versionFileName}-${i}.zip`,
label: 'Waiting. . .',
downloaded: 0,
totalSize: 0,
progress: 0,
percent: 0,
url: shard,
})
);
const fabricProgress = ref<ProgressBoxType>({
label: 'Fabric - Waiting . . .',
percent: 0,
progress: 0,
img: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB50lEQVRYhd2YTU7bYBCGn7GyoF0Eu17EpyARS1hEogeI1IXbs/QAvUpJFogcAESkwhIBvQRUMna9ABaQr4tgk9j5lSd1zLNybI8y7ze/shx3z+j4bfq9gaGCdPy29HsDxBhDvzcwIoLtfCjbr5WIwkeMMXT8tshx98wAWJawbVdLyN/okeFwlEg1AOfTx/Sh69bL8WpFgiBODz68fxgJSUhEbNVrecsN4il+xnXrBEGc3rOyL226CJjuo4WU4Ik2Apa8AyUC1KDY+PD3TiZ+9y4+r9VuFoULouU56fXVbbh2u1kUFvL9aBeAH18uaXlOetKzTtjfO0GApudwfRvSLRiJBPUW1fIcru+iuc9TFMtTTch4ZJoNOxeZb/unDI2h5Tn8/hPx89eB1l8Dkp8jWkycPLDTsNN7yVqhh9FPrWzNfN0/xbxG4uYu4vBcMxJvFBayqLibDTu9Hpp8JBbZL4tK+53WPscjM68mZtmvikqNLGo+L+o1kUelRua5mURm3VhT0rZyGKOUWpaUv3iqrSjZJXAZRISuUjtWmyPZAbgMGt0qQX1FKYu1rSj/m5yQp/i5DD9WYpqPE6kVBDGuW6+EmPEvKPAqJLx/AEbft7IvbDKJ3zBKrfKHQHEkSS0BzLjCCiEA/wAmNq0sQ6WYFQAAAA5lWElmTU0AKgAAAAgAAAAAAAAA0lOTAAAAAElFTkSuQmCC',
});
const modsProgress = ref<ProgressBoxType>({
label: 'Mods - Waiting . . .',
percent: 0,
progress: 0,
img: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB50lEQVRYhd2YTU7bYBCGn7GyoF0Eu17EpyARS1hEogeI1IXbs/QAvUpJFogcAESkwhIBvQRUMna9ABaQr4tgk9j5lSd1zLNybI8y7ze/shx3z+j4bfq9gaGCdPy29HsDxBhDvzcwIoLtfCjbr5WIwkeMMXT8tshx98wAWJawbVdLyN/okeFwlEg1AOfTx/Sh69bL8WpFgiBODz68fxgJSUhEbNVrecsN4il+xnXrBEGc3rOyL226CJjuo4WU4Ik2Apa8AyUC1KDY+PD3TiZ+9y4+r9VuFoULouU56fXVbbh2u1kUFvL9aBeAH18uaXlOetKzTtjfO0GApudwfRvSLRiJBPUW1fIcru+iuc9TFMtTTch4ZJoNOxeZb/unDI2h5Tn8/hPx89eB1l8Dkp8jWkycPLDTsNN7yVqhh9FPrWzNfN0/xbxG4uYu4vBcMxJvFBayqLibDTu9Hpp8JBbZL4tK+53WPscjM68mZtmvikqNLGo+L+o1kUelRua5mURm3VhT0rZyGKOUWpaUv3iqrSjZJXAZRISuUjtWmyPZAbgMGt0qQX1FKYu1rSj/m5yQp/i5DD9WYpqPE6kVBDGuW6+EmPEvKPAqJLx/AEbft7IvbDKJ3zBKrfKHQHEkSS0BzLjCCiEA/wAmNq0sQ6WYFQAAAA5lWElmTU0AKgAAAAgAAAAAAAAA0lOTAAAAAElFTkSuQmCC',
});
const resourcepackProgress = ref<ProgressBoxType>({
label: 'Resource Pack - Waiting . . .',
percent: 0,
progress: 0,
img: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB50lEQVRYhd2YTU7bYBCGn7GyoF0Eu17EpyARS1hEogeI1IXbs/QAvUpJFogcAESkwhIBvQRUMna9ABaQr4tgk9j5lSd1zLNybI8y7ze/shx3z+j4bfq9gaGCdPy29HsDxBhDvzcwIoLtfCjbr5WIwkeMMXT8tshx98wAWJawbVdLyN/okeFwlEg1AOfTx/Sh69bL8WpFgiBODz68fxgJSUhEbNVrecsN4il+xnXrBEGc3rOyL226CJjuo4WU4Ik2Apa8AyUC1KDY+PD3TiZ+9y4+r9VuFoULouU56fXVbbh2u1kUFvL9aBeAH18uaXlOetKzTtjfO0GApudwfRvSLRiJBPUW1fIcru+iuc9TFMtTTch4ZJoNOxeZb/unDI2h5Tn8/hPx89eB1l8Dkp8jWkycPLDTsNN7yVqhh9FPrWzNfN0/xbxG4uYu4vBcMxJvFBayqLibDTu9Hpp8JBbZL4tK+53WPscjM68mZtmvikqNLGo+L+o1kUelRua5mURm3VhT0rZyGKOUWpaUv3iqrSjZJXAZRISuUjtWmyPZAbgMGt0qQX1FKYu1rSj/m5yQp/i5DD9WYpqPE6kVBDGuW6+EmPEvKPAqJLx/AEbft7IvbDKJ3zBKrfKHQHEkSS0BzLjCCiEA/wAmNq0sQ6WYFQAAAA5lWElmTU0AKgAAAAgAAAAAAAAA0lOTAAAAAElFTkSuQmCC',
});
const fabricClick = async () => {
processingFabric.value = true;
disableBackNav.value = true;
fabricDisabled.value = true;
fabricProgress.value.img =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAByklEQVRYhd2YTVLCQBCFX6dYqIsIztyHI7DjGpYuRV2ouNTyGGRFbgD3yRDMAlhQtIs4KfKHhEwS4rcKSaboN6+7pys0ncwwGPbhOnNGCxkM++Q6cxAzw3XmTETo9i6bjqsQS38NZsZg2CeaTmYMAJZFuO62S8j3co3dLkykDgD0bq6ih0LYzURVEKWCaOP9xSoUotEiLuxOeuUZsQm2EMKGUkF0z0q+dO4igOwYLVADkZiGAIv+gRIC0AHKHR+jh6fY7/H7a6Xr8ihdEFLK6NrzvMrX5UGuM+NuL2y/QtgnF/vnx1csqLwd1k5IKeF53slObIJt1LWW/qq8I0mklFBKHXxeBcYc0eQ58zh6BjNHQt/GL6X+J+7IOn2OmCK580KI6B6z6fmUzTui0c4opYw6oTFeI7p484pWCBFdZznx1/pjMdJ+s9rn3f0tgNCZQ07krS9KZTWyj/maSFP5hKidqRqrhs2qHGZDqUXU/OBZOrV06iSHwGMgImPt2FiNnDJ6mOhWGmNC6irqPGppv3WQErIJtk3EUYisGGOppVQAIexWiNn/ggL8CvEXKwDh963kC+eMjhsIU6v5Q6A8pFOLAPC+whZBAPAD4SrOvdEMgKQAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg==';
installFabric(fabricProgress);
return;
};
const modsClick = async () => {
processingMods.value = true;
disableBackNav.value = true;
modsDisabled.value = true;
modsProgress.value.img =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAByklEQVRYhd2YTVLCQBCFX6dYqIsIztyHI7DjGpYuRV2ouNTyGGRFbgD3yRDMAlhQtIs4KfKHhEwS4rcKSaboN6+7pys0ncwwGPbhOnNGCxkM++Q6cxAzw3XmTETo9i6bjqsQS38NZsZg2CeaTmYMAJZFuO62S8j3co3dLkykDgD0bq6ih0LYzURVEKWCaOP9xSoUotEiLuxOeuUZsQm2EMKGUkF0z0q+dO4igOwYLVADkZiGAIv+gRIC0AHKHR+jh6fY7/H7a6Xr8ihdEFLK6NrzvMrX5UGuM+NuL2y/QtgnF/vnx1csqLwd1k5IKeF53slObIJt1LWW/qq8I0mklFBKHXxeBcYc0eQ58zh6BjNHQt/GL6X+J+7IOn2OmCK580KI6B6z6fmUzTui0c4opYw6oTFeI7p484pWCBFdZznx1/pjMdJ+s9rn3f0tgNCZQ07krS9KZTWyj/maSFP5hKidqRqrhs2qHGZDqUXU/OBZOrV06iSHwGMgImPt2FiNnDJ6mOhWGmNC6irqPGppv3WQErIJtk3EUYisGGOppVQAIexWiNn/ggL8CvEXKwDh963kC+eMjhsIU6v5Q6A8pFOLAPC+whZBAPAD4SrOvdEMgKQAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg==';
downloadMods(modsProgress);
return;
};
const resourcepackClick = async () => {
processingResourcepack.value = true;
disableBackNav.value = true;
resourcepackDisabled.value = true;
resourcepackProgress.value.img =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAAByklEQVRYhd2YTVLCQBCFX6dYqIsIztyHI7DjGpYuRV2ouNTyGGRFbgD3yRDMAlhQtIs4KfKHhEwS4rcKSaboN6+7pys0ncwwGPbhOnNGCxkM++Q6cxAzw3XmTETo9i6bjqsQS38NZsZg2CeaTmYMAJZFuO62S8j3co3dLkykDgD0bq6ih0LYzURVEKWCaOP9xSoUotEiLuxOeuUZsQm2EMKGUkF0z0q+dO4igOwYLVADkZiGAIv+gRIC0AHKHR+jh6fY7/H7a6Xr8ihdEFLK6NrzvMrX5UGuM+NuL2y/QtgnF/vnx1csqLwd1k5IKeF53slObIJt1LWW/qq8I0mklFBKHXxeBcYc0eQ58zh6BjNHQt/GL6X+J+7IOn2OmCK580KI6B6z6fmUzTui0c4opYw6oTFeI7p484pWCBFdZznx1/pjMdJ+s9rn3f0tgNCZQ07krS9KZTWyj/maSFP5hKidqRqrhs2qHGZDqUXU/OBZOrV06iSHwGMgImPt2FiNnDJ6mOhWGmNC6irqPGppv3WQErIJtk3EUYisGGOppVQAIexWiNn/ggL8CvEXKwDh963kC+eMjhsIU6v5Q6A8pFOLAPC+whZBAPAD4SrOvdEMgKQAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg==';
downloadResourcePack(resourcepackProgress);
return;
};
</script>

<style scoped lang="sass">
.top-btn
width: 100%
// margin-bottom: 10px
// height:
.bottom-btns
display: flex
flex-direction: row
justify-content: center
align-items: center
gap: 5px
.bottom-btns > div
width: 34%
.center
display: flex
flex-direction: column
justify-content: center
align-items: center
</style>
Loading

0 comments on commit 79c568b

Please sign in to comment.