Skip to content

Commit

Permalink
Merge pull request #170 from gorilla-devs/develop
Browse files Browse the repository at this point in the history
v0.11.9
  • Loading branch information
blarfoon authored Mar 15, 2019
2 parents c9aa16c + 46f0607 commit 97430ff
Show file tree
Hide file tree
Showing 18 changed files with 1,186 additions and 708 deletions.
37 changes: 24 additions & 13 deletions app/actions/downloadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { promisify } from 'util';
import axios from 'axios';
import makeDir from 'make-dir';
import fse from 'fs-extra';
import { cpus } from 'os';
import dirTree from 'directory-tree';
import log from 'electron-log';
import Promise from 'bluebird';
import fs, { readdir } from 'fs';
import fs, { readdir, copyFile } from 'fs';
import compressing from 'compressing';
import { downloadFile, downloadArr } from '../utils/downloader';
import {
Expand Down Expand Up @@ -99,7 +100,7 @@ export function addCursePackToQueue(pack, addonID, fileID) {
'temp',
path.basename(packURL)
);
await downloadFile(tempPackPath, packURL, () => {});
await downloadFile(tempPackPath, packURL, () => { });
await compressing.zip.uncompress(
tempPackPath,
path.join(INSTANCES_PATH, 'temp', pack)
Expand Down Expand Up @@ -209,7 +210,7 @@ export function downloadPack(pack) {
} catch (err) {
const { data } = await axios.get(
`https://addons-ecs.forgesvc.net/api/minecraft/modloader/forge-${
currPack.forgeVersion
currPack.forgeVersion
}`
);

Expand Down Expand Up @@ -275,9 +276,9 @@ export function downloadPack(pack) {
const legacyJavaFixer =
vCompare(currPack.forgeVersion, '10.13.1.1217') === -1
? {
url: GDL_LEGACYJAVAFIXER_MOD_URL,
path: path.join(PACKS_PATH, pack, 'mods', 'LJF.jar')
}
url: GDL_LEGACYJAVAFIXER_MOD_URL,
path: path.join(PACKS_PATH, pack, 'mods', 'LJF.jar')
}
: null;

// Here we work on the mods
Expand Down Expand Up @@ -356,12 +357,27 @@ export function downloadPack(pack) {
}
});
},
{ concurrency: 4 }
{ concurrency: cpus().length + 2 }
);
} catch (err) {
log.error(err);
}

if (thumbnailURL !== null) {
// Download the thumbnail
await downloadFile(
path.join(PACKS_PATH, pack, 'thumbnail.png'),
thumbnailURL,
() => { }
);

// Copy the thumbnail as icon
await promisify(copyFile)(
path.join(PACKS_PATH, pack, 'thumbnail.png'),
path.join(PACKS_PATH, pack, 'icon.png')
);
}

await promisify(fs.writeFile)(
path.join(PACKS_PATH, pack, 'config.json'),
JSON.stringify({
Expand All @@ -372,6 +388,7 @@ export function downloadPack(pack) {
: `forge-${currPack.forgeVersion}`,
...(currPack.addonID && { projectID: currPack.addonID }),
...(modpackVersion && { modpackVersion }),
...(thumbnailURL && { icon: 'icon.png' }),
timePlayed: 0,
mods: modsManifest,
overrideFiles: overrideFilesList
Expand Down Expand Up @@ -399,12 +416,6 @@ export function downloadPack(pack) {
}
});
};
if (thumbnailURL !== null)
await downloadFile(
path.join(PACKS_PATH, pack, 'thumbnail.png'),
thumbnailURL,
() => {}
);

const allFiles =
legacyJavaFixer !== null
Expand Down
4 changes: 3 additions & 1 deletion app/actions/instancesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ export function selectInstance(name) {
export function startInstance(instanceName) {
return async (dispatch, getState) => {
const { auth, settings } = getState();

const command = await launchCommand(
instanceName,
auth,
settings.java.memory
settings.java.memory,
settings.java.javaArgs
);
const start = spawn(command, [], {
shell: true,
Expand Down
16 changes: 14 additions & 2 deletions app/actions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import log from 'electron-log';
import { message } from 'antd';
import _ from 'lodash';
import store from '../localStore';
import { THEMES } from '../constants';
import { THEMES, DEFAULT_ARGS } from '../constants';

export const LOAD_SETTINGS = 'LOAD_SETTINGS';
export const SET_SOUNDS = 'SET_SOUNDS';
export const SET_JAVA_PATH = 'SET_JAVA_PATH';
export const SET_JAVA_MEMORY = 'SET_JAVA_MEMORY';
export const SET_THEME = 'SET_THEME';
export const RESET_THEME = 'RESET_THEME';
export const SET_GLOBAL_JAVA_ARGUMENTS = 'SET_GLOBAL_JAVA_ARGUMENTS';

export function loadSettings() {
return dispatch => {
Expand All @@ -31,7 +32,8 @@ export function loadSettings() {
const javaSettings = {
autodetected: true,
path: null,
memory: 3072
memory: 3072,
javaArgs: DEFAULT_ARGS
};
if (
!settings.java ||
Expand Down Expand Up @@ -148,3 +150,13 @@ export function applyTheme(theme) {
}
};
}

export function setJavaArgs(args) {
return dispatch => {
dispatch({
type: SET_GLOBAL_JAVA_ARGUMENTS,
payload: args
});
dispatch(saveSettings());
};
}
54 changes: 35 additions & 19 deletions app/components/ChangelogModal/ChangelogModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,68 @@ export default props => {
history={props.history}
unMount={unMount}
title="WHAT'S NEW"
style={{ height: 390, width: 540 }}
style={{ height: '70vh', width: 540 }}
>
<div className={styles.container}>
<h2 className={styles.hrTextGreen}>SOME COOL NEW STUFF</h2>
<div className={styles.subHrList}>
<ul>
<ChangelogRow
main="Added a modal dialog confirmation"
secondary="when deleting an instance"
main="We are refactoring quite a few parts of the code"
secondary=", this will allow us to easily add features later on"
/>
<ChangelogRow
main="Added a modal to fix _JAVA_OPTIONS"
secondary="because it caused a lot of troubles"
main="Drastically improved rendering performance"
secondary=", it should now be 2x faster"
/>
<ChangelogRow
main="We are trying to make the UI as consistent as possible"
secondary=", so we changed some visual effects. You shouldn't notice it"
main="Modpacks icons are automatically set as instance icon when downloading them"
secondary=""
/>
<ChangelogRow
main="Added our brand new Patreon page link in the Home"
secondary=". Wait, what??? Didn't you donate yet! SHAME ON U!11!1"
main="Modpacks downloads should now be 4x faster"
secondary="depending on your connection"
/>
<ChangelogRow
main="We now show the 'Playing on GDLauncher' presence on discord"
secondary="hurraah!"
/>
<ChangelogRow
main="Updated the download progress style when downloading instances"
secondary="do you like it??"
/>
<ChangelogRow
main="You can now change the java arguments from the launcher settings!"
secondary="It will apply to all the instances"
/>
<ChangelogRow
main="Instances now have an animation when appearing."
secondary="This will fix icons 'flashing' for a split second"
/>
</ul>
</div>
<h2 className={styles.hrTextRed}>SOME BUGFIXES</h2>
<div className={styles.subHrList}>
<ul>
<ChangelogRow
main="Fixed a bug when downloading mods"
secondary="we hope you are proud of us now :)"
main="Fixed the news not working"
secondary=", not our fault. Minecraft.net changed it..."
/>
<ChangelogRow
main="When searching for a mod that doesn't exist"
secondary="it now displays an appropriate message"
main="Removed various errors stacking up"
secondary="when java was not found"
/>
<ChangelogRow
main="Modals animation should feel smoother now"
secondary="let us know if you agree"
main="Fixed mods dependancies not being correctly downloaded"
secondary=" yeeeee"
/>
<ChangelogRow
main="Fixed compatibility issues with older versions of the launcher"
secondary={`, if instances still won't start, try clicking "repair" and try again`}
main="Fixed broken mods and modpacks results"
secondary="when the text contained whitespaces"
/>
<ChangelogRow
main="Fixed access token being written to logs"
secondary={`, you're safe now!`}
main="Fixed closing modal animation not working"
secondary="when creating a new instance"
/>
</ul>
</div>
Expand Down
49 changes: 24 additions & 25 deletions app/components/DInstance/DInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ export default class DInstance extends Component<Props> {
this.interval = setInterval(() => {
this.updateInstanceConfig();
}, 1000);

const config = JSON.parse(
await promisify(fs.readFile)(
path.join(PACKS_PATH, this.props.name, 'config.json')
)
);
if (config.icon) {
const icon = await promisify(fs.readFile)(
path.join(PACKS_PATH, this.props.name, config.icon)
);
this.setState({
icon: `url("data:image/png;base64,${icon.toString('base64')}")`
});
}
};

componentDidUpdate = () => {
Expand All @@ -91,12 +77,16 @@ export default class DInstance extends Component<Props> {
)
);
const { version, forgeVersion } = config;

// Tries to read the instance config file and updates the icon accordingly
if (config.icon) {
const icon = await promisify(fs.readFile)(
path.join(PACKS_PATH, this.props.name, config.icon)
);
this.setState({
icon: `url("data:image/png;base64,${icon.toString('base64')}")`
icon: `url("data:image/png;base64,${icon.toString(
'base64'
)}") center no-repeat`
});
} else {
this.setState({
Expand All @@ -113,10 +103,10 @@ export default class DInstance extends Component<Props> {
: forgeVersion
});
} catch (e) {
console.log(e);
this.setState({
version: 'Error',
isValid: false
isValid: false,
icon: `url(${InstanceIcon}) center no-repeat`
});
}
}
Expand Down Expand Up @@ -168,7 +158,7 @@ export default class DInstance extends Component<Props> {

render = () => {
const { name, selectedInstance, selectInstance, playing } = this.props;
const { version, isValid, forgeVersion } = this.state;
const { version, isValid, forgeVersion, icon } = this.state;
return (
<div
className={`${selectedInstance === name ? styles.selectedItem : ''} ${
Expand Down Expand Up @@ -218,7 +208,11 @@ export default class DInstance extends Component<Props> {
<div
className={styles.icon__image}
style={{
background: this.state.icon,
background:
version !== null || this.isInstalling()
? icon
: 'rgba(0, 0, 0, 0)',
opacity: version !== null || this.isInstalling() ? 1 : 0,
filter: this.isInstalling()
? "url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='grayscale'><feColorMatrix type='matrix' values='0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0'/></filter></svg>#grayscale\")"
: ''
Expand All @@ -227,14 +221,19 @@ export default class DInstance extends Component<Props> {
<span className={styles.icon__instanceNameContainer}>
<span
className={styles.icon__instanceName}
style={{ width: this.isInstalling() ? '76px' : '120px' }}
style={{ width: 120 }}
>
{name}
</span>
<span className={styles.icon__instancePercentage}>
{this.isInstalling() && ` (${this.updatePercentage()}%)`}
</span>
</span>
{this.isInstalling() && (
<span className={styles.progressBarContainer}>
<span className={styles.progressBar} />
<span className={styles.actualProgress}>
<span style={{ width: `${this.updatePercentage()}%` }} />
</span>
</span>
)}
</div>
</div>
</ContextMenuTrigger>
Expand Down Expand Up @@ -353,7 +352,7 @@ export default class DInstance extends Component<Props> {
</span>{' '}
Export
</MenuItem>
<MenuItem
{/* <MenuItem
disabled={
this.isInstalling() ||
!isValid ||
Expand All @@ -365,7 +364,7 @@ export default class DInstance extends Component<Props> {
<FontAwesomeIcon icon={faWrench} />
</span>{' '}
Repair
</MenuItem>
</MenuItem> */}
<MenuItem
disabled={
this.isInstalling() || playing.find(el => el.name === name)
Expand Down
29 changes: 28 additions & 1 deletion app/components/DInstance/DInstance.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
.icon__image {
width: 90px;
height: 90px;
border-radius: 2px;
border-radius: 50%;
background-size: 90px !important;
transition: opacity 0.1s ease-in-out;
}

.main:hover {
Expand Down Expand Up @@ -106,3 +107,29 @@
}
}
}
.progressBarContainer {
height: 4px;
position: absolute;
width: 100%;
left: 0px;
bottom: 4px;
display: flex;
justify-content: center;
.progressBar {
height: 100%;
width: 80%;
background-color: var(--secondary-color-3);
}
.actualProgress {
position: absolute;
height: 100%;
width: 80%;
span {
position: absolute;
left: 0;
height: 100%;
background-color: var(--primary);
z-index: 1000000;
}
}
}
Loading

0 comments on commit 97430ff

Please sign in to comment.