Skip to content

Commit

Permalink
installer now references manifest file for sources, updated ci ubuntu…
Browse files Browse the repository at this point in the history
… to 24.04

- installer version bump to v1.1.0
- included WIP (commented) code for user-selected version from manifest file
  • Loading branch information
jgaribsin committed Jul 14, 2024
1 parent 2e76f0b commit 441a578
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
include:
- kind: linux
os: ubuntu-latest
os: ubuntu-24.04
platform: linux
- kind: windows
os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drehmal-installer",
"version": "1.0.3",
"version": "1.1.0",
"description": "Drehmal, Minecraft map installer",
"productName": "Drehmal Installer",
"author": "Primordial Team",
Expand Down
5 changes: 5 additions & 0 deletions src-electron/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ ipcMain.handle('getDrehmalPath', () => {
}
});

ipcMain.handle('getManifestData', async (_event, url) => {
const response = await fetch(url);
return await response.json();
});

ipcMain.handle(
'openFileDialog',
async () =>
Expand Down
159 changes: 100 additions & 59 deletions src/pages/InstallationType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,85 @@
<div class="body">
<!-- Body Content -->
<div class="q-pa-sm fixed-center selector">
<q-list bordered separator>
<q-item
clickable
v-ripple
to="/singleplayer/"
@click="typeSelect('singleplayer')"
>
<q-item-section>
<q-item-label header class="text-info text-h5"
>Singleplayer Installation</q-item-label
>
<q-item-label class="text-accent"
>For playing in singleplayer</q-item-label
>
<q-item-label
>Includes: Drehmal Map, Resource Pack, Fabric Client, and
Client-Side Mods.</q-item-label
>
</q-item-section>
</q-item>
<q-item
clickable
v-ripple
to="/multiplayer/"
@click="typeSelect('multiplayer')"
>
<q-item-section>
<q-item-label header class="text-info text-h5"
>Multiplayer Installation</q-item-label
>
<q-item-label class="text-accent"
>For playing on multiplayer servers</q-item-label
>
<q-item-label
>Includes: Resource Pack, Fabric Client, and Client-Side
Mods.</q-item-label
>
</q-item-section>
</q-item>
<!-- <div>
NOTE: UNFINISHED. WIP for allowing user-selected version
<q-select
hint="Selected Version"
stack-label
dark
item-aligned
input-class="center"
color="accent"
v-model="selectedVersion"
:options="sources"
@input-value="sourceSelect"
style="width: 50%"
bg-color="primary"
<q-item
clickable
v-ripple
to="/server/"
@click="typeSelect('server')"
>
<q-item-section>
<!-- <q-item-label overline>Coming Soon!</q-item-label> -->
<q-item-label header class="text-info text-h5"
>Server Installation</q-item-label
>
<q-item-label class="text-accent"
>For hosting a multiplayer server.</q-item-label
>
<q-item-label
>Includes: Drehmal Map, Minecraft Server Jar.</q-item-label
>
</q-item-section>
</q-item>
</q-list>
></q-select>
</div> -->

<div>
<q-list bordered separator>
<q-item
clickable
v-ripple
to="/singleplayer/"
@click="typeSelect('singleplayer')"
>
<q-item-section>
<q-item-label header class="text-info text-h5"
>Singleplayer Installation
</q-item-label>
<q-item-label class="text-accent"
>For playing in singleplayer
</q-item-label>
<q-item-label
>Includes: Drehmal Map, Resource Pack, Fabric Client, and
Client-Side Mods.
</q-item-label>
</q-item-section>
</q-item>
<q-item
clickable
v-ripple
to="/multiplayer/"
@click="typeSelect('multiplayer')"
>
<q-item-section>
<q-item-label header class="text-info text-h5"
>Multiplayer Installation
</q-item-label>
<q-item-label class="text-accent"
>For playing on multiplayer servers
</q-item-label>
<q-item-label
>Includes: Resource Pack, Fabric Client, and Client-Side Mods.
</q-item-label>
</q-item-section>
</q-item>

<q-item
clickable
v-ripple
to="/server/"
@click="typeSelect('server')"
>
<q-item-section>
<!-- <q-item-label overline>Coming Soon!</q-item-label> -->
<q-item-label header class="text-info text-h5"
>Server Installation
</q-item-label>
<q-item-label class="text-accent"
>For hosting a multiplayer server.
</q-item-label>
<q-item-label
>Includes: Drehmal Map, Minecraft Server Jar.
</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>
</q-page>
Expand All @@ -72,12 +91,32 @@
import { storeToRefs } from 'pinia';
import { useInstallerStore } from 'src/stores/InstallerStore';
import { useStateStore } from 'src/stores/StateStore';
import { useSourcesStore } from 'stores/SourcesStore';
const path = require('path');
const { ipcRenderer } = require('electron');
const { versions, selectedVersion, map, resourcePack, server, launcher } =
storeToRefs(useSourcesStore());
const { installType } = storeToRefs(useStateStore());
const { drehmalDir } = storeToRefs(useInstallerStore());
// NOTE: UNFINISHED. WIP for allowing user-selected version
const sources = Object.keys(versions.value);
const sourceSelect = async (value: string) => {
console.log('changed source to:', value);
const mapVersion = versions.value[selectedVersion.value].map.version;
console.log(`Using source: ${selectedVersion.value} (v${mapVersion})`);
map.value = versions.value[selectedVersion.value].map;
resourcePack.value = versions.value[selectedVersion.value].resourcepack;
server.value = versions.value[selectedVersion.value].server;
launcher.value = versions.value[selectedVersion.value].launcher;
console.log(
`Updated map, resource pack, server, and launcher source data with ${selectedVersion.value} sources (v${mapVersion})`
);
};
const typeSelect = async (type: 'singleplayer' | 'multiplayer' | 'server') => {
console.log(`Selected installation type: ${type}`);
installType.value = type;
Expand All @@ -100,10 +139,12 @@ const typeSelect = async (type: 'singleplayer' | 'multiplayer' | 'server') => {
font-size: 48px;
padding: 10px;
}
.header img {
height: 2em;
vertical-align: middle;
}
.selector {
width: 100%;
}
Expand Down
44 changes: 27 additions & 17 deletions src/pages/WelcomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { useInstallerStore } from 'src/stores/InstallerStore';
import { useSourcesStore } from 'src/stores/SourcesStore';
import { useStateStore } from 'src/stores/StateStore';
import SponsorPartner from 'src/components/SponsorPartner.vue';
const path = require('path');
const { ipcRenderer } = require('electron');
const fs = require('fs');
// Ensure these are initialised; Be careful if removing
useSourcesStore();
Expand All @@ -34,7 +34,15 @@ useInstallerStore();
const { homeDir, appDir, minecraftDir, memory } = storeToRefs(
useInstallerStore()
);
const { map, resourcePack } = storeToRefs(useSourcesStore());
const {
manifest,
selectedVersion,
versions,
map,
resourcePack,
server,
launcher,
} = storeToRefs(useSourcesStore());
const { customConfig } = storeToRefs(useStateStore());
ipcRenderer.invoke('getMinecraftPath').then((minecraft) => {
Expand All @@ -47,23 +55,25 @@ ipcRenderer.invoke('getAppDataPath').then((appData) => {
homeDir.value = appData;
appDir.value = path.join(appData, 'Drehmal Installer');
memory.value = 4;
// check if config file exists at path
const configPath = path.join(appDir.value, 'config.json');
if (fs.existsSync(configPath)) {
console.log(`Installer config found at "${configPath}", loading`);
customConfig.value = true;
const rawData = fs.readFileSync(configPath, 'utf-8');
const configData = JSON.parse(rawData);
map.value = configData.map;
console.log(
`${map.value.versionName} has ${map.value.shards.length} shards`
);
resourcePack.value = configData.resourcePack;
}
});
// Drehmal path not set here, will be set after user selects an installation type
// src/pages/InstallPage.vue
ipcRenderer.invoke('getManifestData', manifest.value).then((data) => {
console.log(`Fetched manifest data from "${manifest.value}"`);
versions.value = data;
const sources = Object.keys(data);
console.log(`Got manifest data for the following sources: ${sources}`);
// If "latest" exists in version list, use it; otherwise use the first version
selectedVersion.value = sources.includes('latest') ? 'latest' : sources[0];
const mapVersion = data[selectedVersion.value].map.version;
console.log(`Using source: "${selectedVersion.value}" (v${mapVersion})`);
map.value = data[selectedVersion.value].map;
resourcePack.value = data[selectedVersion.value].resourcepack;
server.value = data[selectedVersion.value].server;
launcher.value = data[selectedVersion.value].launcher;
console.log(
`Updated map, resource pack, server, and launcher source data with "${selectedVersion.value}" sources (v${mapVersion})`
);
});
</script>
<style scoped lang="sass">
p
Expand Down
2 changes: 1 addition & 1 deletion src/providers/DownloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function downloadFile(
// User-Agent: github_username/project_name/1.56.0 (launcher.com)
const options = {
headers: {
'User-Agent': 'Drehmal-Team/installer/1.0.2 (drehmal.net)',
'User-Agent': 'Drehmal-Team/installer/1.1.0 (drehmal.net)',
// 'accept-encoding': 'gzip, deflate, br',
},
};
Expand Down
Loading

0 comments on commit 441a578

Please sign in to comment.