Skip to content

Commit

Permalink
profiles have their flavor displayed. the login page will generate a …
Browse files Browse the repository at this point in the history
…clientKey if it is missing.
  • Loading branch information
mworzala committed Jul 13, 2019
1 parent 5ecb76b commit 1d6da3e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 148 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "proton",
"version": "0.2.11",
"version": "0.2.12",
"description": "A custom minecraft launcher",
"private": false,
"author": "Matt Worzala <bhop.me>",
Expand Down Expand Up @@ -57,6 +57,10 @@
"src/**",
"*.js"
],
"protocols": [{
"name": "Proton Launcher",
"schemes": ["proton"]
}],
"extends": null,
"directories": {
"buildResources": "assets"
Expand Down
10 changes: 4 additions & 6 deletions src/main/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ exports.loadConfig = async () => {
while (maxMem % 128 !== 0)
maxMem++;

if (!created) {
if (!created)
this.setValue('defaults/maxMemory', maxMem / 2);
this.setValue('clientKey', Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15));
}

if (this.getValue('app/instanceDir').length === 0) {
if (this.getValue('app/instanceDir').length === 0)
this.setValue('app/instanceDir', path.join(baseDir, 'Instances'));
this.saveConfig();
}

this.saveConfig();
};

exports.addEventListener = (target, callback) => {
Expand Down
63 changes: 0 additions & 63 deletions src/main/launcher/LegacyLauncher.js

This file was deleted.

73 changes: 0 additions & 73 deletions src/main/launcher/NativeLauncher.js

This file was deleted.

13 changes: 11 additions & 2 deletions src/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,19 @@ const createContextMenu = () => {
])
};
const registerUriListeners = () => {
app.setAsDefaultProtocolClient('proton');

const locked = app.requestSingleInstanceLock();
if (!locked)
app.quit();
app.on('second-instance', (event, argv, cwd) => {
console.log('WOW A NEW INSTANCE HAS BEEN LAUNCHED');
console.log(event);
console.log('--------------------------------');
console.log(argv);
console.log('--------------------------------');
console.log(cwd);
console.log('--------------------------------');

mainWindow.show();
})
Expand Down Expand Up @@ -170,10 +179,10 @@ app.on('ready', async () => {
// createTrayMenu();
// if (process.platform === 'win32')
// createContextMenu();
// registerUriListeners();
registerUriListeners();

// Send warning about not pasting stuff.
mainWindow.webContents.on('devtools-opened', () => mainWindow.webContents.send('devtools-opened'));
// mainWindow.webContents.on('devtools-opened', () => mainWindow.webContents.send('devtools-opened'));
}, 100);
});

Expand Down
4 changes: 4 additions & 0 deletions src/main/mojang/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ exports.addAccount = () => {
}
});
window.loadURL(`file://${__dirname}/login.html`).then(() => ipcMain.on('login:complete', async (event, data) => {
if (data.clientKey !== config.getValue('clientKey')) {
config.setValue('clientKey', data.clientKey);
await config.saveConfig();
}
const acc = await this.getAccount(data.uuid);
if (acc != null) {
acc.token = data.token;
Expand Down
6 changes: 4 additions & 2 deletions src/main/mojang/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
const mojang = require('../mojang/mojang');

const login = async () => {
const clientKey = (await require('fs-extra').readJson(require('path').join(require('electron').remote.app.getPath('userData'), 'launcher_config.json'))).clientKey;
console.log(clientKey);
let clientKey = (await require('fs-extra').readJson(require('path').join(require('electron').remote.app.getPath('userData'), 'launcher_config.json'))).clientKey;
if (!clientKey)
clientKey = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const resp = await mojang.login(username, password, clientKey, true);
Expand All @@ -23,6 +24,7 @@
login: resp.user.username,
username: resp.availableProfiles[0].name,
selected: false,
clientKey
});
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/render/profiles/profiles.less
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@

.profile-flavor {
position: absolute;
right: 10px;
right: 15px;
top: 10px;

font-size: 15px;
color: @superOffWhite;
text-shadow: 2px 2px @offBlack;
z-index: 5;
}

img {
Expand Down

0 comments on commit 1d6da3e

Please sign in to comment.