Skip to content

Commit

Permalink
Merge pull request #134 from gorilla-devs/develop
Browse files Browse the repository at this point in the history
v0.9.3
  • Loading branch information
blarfoon authored Jan 6, 2019
2 parents 2b04a1c + 003a9ac commit 479d76c
Show file tree
Hide file tree
Showing 19 changed files with 185 additions and 445 deletions.
413 changes: 11 additions & 402 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/actions/downloadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { promisify } from 'util';
import axios from 'axios';
import makeDir from 'make-dir';
import fse from 'fs-extra';
import log from 'electron-log';
import Promise from 'bluebird';
import fs from 'fs';
import Zip from 'adm-zip';
Expand Down Expand Up @@ -238,7 +239,7 @@ export function downloadPack(pack) {
);
mods = await getModsList(manifest.files, pack);
} catch (err) {
console.error(err);
log.error(err);
}

const totalFiles =
Expand Down
6 changes: 3 additions & 3 deletions app/actions/instancesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export function startInstance(instanceName) {
{ cwd: path.join(PACKS_PATH, instanceName) },
(error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
log.error(`Cannot start this instance. Error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
log.log(`stdout: ${stdout}`);
log.log(`stderr: ${stderr}`);
}
);
dispatch({
Expand Down
6 changes: 5 additions & 1 deletion app/actions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export function loadSettings() {
const javaSettings = {
autodetected: true, path: null, memory: 3072
};
if (!settings.java || Object.keys(settings.java).length === 0 || isLegacy(javaSettings, settings.java)) {
if (!settings.java ||
Object.keys(settings.java).length === 0 ||
isLegacy(javaSettings, settings.java) ||
typeof settings.java.memory != 'number'
) {
store.set('settings.java', javaSettings);
}
// Reads the settings again after patching
Expand Down
13 changes: 13 additions & 0 deletions app/app.global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ a:hover {
background: var(--secondary-color-2);
}

.ant-slider-track, .ant-slider:hover .ant-slider-track {
background-color: var(--primary);
}

.ant-slider-handle,
.ant-slider-dot-active,
.ant-slider:hover .ant-slider-handle:not(.ant-tooltip-open),
.ant-slider-handle .ant-tooltip-open {
background-color: var(--secondary-color-3);
border: solid 2px var(--primary);
border-color: var(--primary) !important;
}

.container {
max-width: 24rem;
margin: 1rem auto;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useState, useEffect } from 'react';
import ContentLoader from 'react-content-loader';
import axios from 'axios';
import Modal from '../Common/Modal/Modal';
import { CURSEMETA_API_URL } from '../../constants';
import styles from './CurseModpackExplorerModal.scss';

const Loader = () => <ContentLoader
height="100%"
width="100%"
speed={0.6}
primaryColor="var(--secondary-color-2)"
secondaryColor="var(--secondary-color-3)"
style={{
height: '100%',
width: '100%'
}}
>
<rect x="25%" y="50" rx="0" ry="0" width="55%" height="50" />
{[...Array(Math.round(window.innerHeight / 85))].map((v, i) => <rect x="15%" y={(i * 50) + 120} rx="0" ry="0" width="75%" height="30" />)}

</ContentLoader>;

export default props => {
const { addonID } = props.match.params;
const [unMount, setUnMount] = useState(false);
const [packData, setPackData] = useState(null);

useEffect(async () => {
const { data } = await axios.get(`${CURSEMETA_API_URL}/direct/addon/${addonID}`);
setPackData(data);
}, []);

return (
<Modal
history={props.history}
unMount={unMount}
title="Modpack Explorer"
style={{ height: '80vh', width: '80vw', left: '10%' }}
>
{packData !== null ? <div className={styles.container}>
<h1>{packData.name}</h1>
<div className={styles.description}>
<span
dangerouslySetInnerHTML={{
__html: packData.fullDescription
}}
/>
</div>
</div> : <Loader />}
</Modal>
)
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.container {
display: block;
width: 100%;
height: 100%;
text-align: center;
overflow-y: auto;
padding: 30px;
}

.description {
margin-right: 20px;
img {
max-width: 100%;
height: auto;
}
}
44 changes: 26 additions & 18 deletions app/components/CurseModpacksBrowser/CurseModpacksBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@ import styles from './CurseModpacksBrowser.scss';
function CurseModpacksBrowser(props) {

const [packs, setPacks] = useState([]);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [filterType, setFilterType] = useState('Featured');
const [searchQuery, setSearchQuery] = useState('');

useEffect(() => {
loadPacks();
}, [filterType])

const loadPacks = async (reset = true) => {
const loadPacks = async (reset = true, emptySearch = false) => {
setLoading(true);
const loadingArr = [...new Array(15)].map(() => ({ loading: true, name: null }));
if (reset === true) setPacks(loadingArr);
else setPacks(packs.concat(loadingArr));
else setPacks(packs => packs.concat(loadingArr));

const res = await axios.get(
`${CURSEMETA_API_URL}/direct/addon/search?gameId=432&pageSize=15&index=${
packs.length}&sort=${filterType}&searchFilter=${encodeURI(searchQuery)}&categoryId=0&sectionId=4471&sortDescending=${filterType !==
reset === true ? 0 : packs.length}&sort=${filterType}&searchFilter=${emptySearch === true ? '' : encodeURI(searchQuery)}&categoryId=0&sectionId=4471&sortDescending=${filterType !==
'author' && filterType !== 'name'}`
);
// We now remove the previous 15 elements and add the real 15
const data = reset === true ? res.data : packs.concat(res.data);
setPacks(data); console.log(packs);
setPacks(data);

setLoading(false);
};


const loadMore =
!loading && packs.length !== 0 ? (
!loading && packs.length !== 0 && packs.length % 15 === 0 ? (
<div
style={{
textAlign: 'center',
Expand All @@ -71,15 +71,15 @@ function CurseModpacksBrowser(props) {
};

const onSearchSubmit = async () => {
loadPacks(true);
loadPacks();
};

const emitEmptySearchText = async () => {
setSearchQuery('');
loadPacks(true, true);
};

const downloadLatest = (modpackData) => {
console.log(modpackData);
props.addCursePackToQueue('test', modpackData.id, modpackData.defaultFileId)
};

Expand Down Expand Up @@ -115,16 +115,16 @@ function CurseModpacksBrowser(props) {
<div>
Sort By{' '}
<Select
defaultValue="featured"
defaultValue="Featured"
onChange={filterChanged}
style={{ width: 150 }}
>
<Select.Option value="featured">Featured</Select.Option>
<Select.Option value="popularity">Popularity</Select.Option>
<Select.Option value="lastupdated">Last Updated</Select.Option>
<Select.Option value="name">Name</Select.Option>
<Select.Option value="author">Author</Select.Option>
<Select.Option value="totaldownloads">
<Select.Option value="Featured">Featured</Select.Option>
<Select.Option value="Popularity">Popularity</Select.Option>
<Select.Option value="LastUpdated">Last Updated</Select.Option>
<Select.Option value="Name">Name</Select.Option>
<Select.Option value="Author">Author</Select.Option>
<Select.Option value="TotalDownloads">
Total Downloads
</Select.Option>
</Select>
Expand All @@ -148,7 +148,16 @@ function CurseModpacksBrowser(props) {
>
<Button type="primary" icon="download">Download</Button>
</Link>,
!item.loading && <Button type="primary">Explore <Icon type="arrow-right" /></Button>
!item.loading &&
<Link
to={{
pathname: `/curseModpackExplorerModal/${item.id}`,
state: { modal: true }
}}
><Button type="primary">
Explore <Icon type="arrow-right" />
</Button>
</Link>
]}
>
{item.loading ? (
Expand Down Expand Up @@ -202,10 +211,9 @@ function CurseModpacksBrowser(props) {
}
title={<Link
to={{
pathname: ``,
pathname: `/curseModpackExplorerModal/${item.id}`,
state: { modal: true }
}}
replace
>
{item.name}
</Link>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const CurseModpackBrowserCreatorModal = props => {
});
};

if (loading) return <div>Loading...</div>;

return (
<Modal
history={props.history}
Expand Down Expand Up @@ -99,6 +97,7 @@ const CurseModpackBrowserCreatorModal = props => {
size="large"
style={{ width: 335, display: 'inline-block' }}
placeholder="Select a version"
loading={loading}
>
{_.reverse(versions.map(addon => <Select.Option key={addon.id}>{addon.fileName}</Select.Option>).slice())}
</Select>
Expand Down
6 changes: 6 additions & 0 deletions app/components/DInstance/DInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ export default class DInstance extends Component<Props> {
>
<FontAwesomeIcon icon='link' /> Create Shortcut
</MenuItem>
{/* <MenuItem
disabled={this.isInstalling() || deleting || !isValid}
onClick={() => {}}
>
<FontAwesomeIcon icon='copy' /> Duplicate
</MenuItem> */}
<MenuItem
disabled={this.isInstalling() || deleting || !isValid}
onClick={() => this.props.addToQueue(name, version, forgeVersion)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class InstanceCreatorModal extends Component<Props> {
options={this.state.versions}
size="large"
showSearch={{ filter: this.filter }}
onChange={value => console.log(value)}
style={{ width: 335, display: 'inline-block' }}
placeholder="Select a version"
/>
Expand Down
12 changes: 6 additions & 6 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export const THEMES = {
'secondary-color-2': '#272b2e',
'secondary-color-3': '#13171a'
},
christmas: {
name: 'Christmas',
primary: '#16A085',
"secondary-color-1": "#4f649d",
"secondary-color-2": "#3b5089",
"secondary-color-3": "#273c75"
bloodyMurder: {
name: 'Bloody Murder',
primary: '#aa1e0f',
"secondary-color-1": "#282c2f",
"secondary-color-2": "#14181b",
"secondary-color-3": "#000407"
}
};
6 changes: 2 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render } from 'react-dom';
import log from 'electron-log';
import { AppContainer, setConfig } from 'react-hot-loader';
import Root from './containers/Root';
import { configureStore, history } from './store/configureStore';
Expand All @@ -11,10 +12,7 @@ if (module.hot)
pureRender: true, // RHL will not change render method
})
const store = configureStore();
console.log(
'%cWelcome to GDLauncher',
'background: #2c3e50; color: white; display: block; font-size:50px;'
);
log.log('Welcome to GDLauncher');
render(
<AppContainer>
<Root store={store} history={history} />
Expand Down
1 change: 1 addition & 0 deletions app/reducers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function Settings(state = initialState, action) {
return {
...state,
java: {
...state.java,
autodetected: action.autodetected,
path: action.path
}
Expand Down
16 changes: 14 additions & 2 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import DManager from './components/DManager/containers/DManagerPage';
import InstanceManagerModal from './components/InstanceManagerModal/containers/InstanceManagerModal';
import Settings from './components/Settings/Settings';
import CurseModpacksBrowser from './components/CurseModpacksBrowser/CurseModpacksBrowser';
import CurseModpacksBrowserCreatorModal from './components/CurseModpacksBrowserCreatorModal/CurseModpacksBrowserCreatorModal';

const Login = lazy(() => import('./components/Login/Login'));
const HomePage = lazy(() => import('./components/Home/containers/HomePage'));
Expand All @@ -30,6 +29,13 @@ const InstanceCreatorModal = lazy(() =>
const loginHelperModal = lazy(() =>
import('./components/LoginHelperModal/LoginHelperModal')
);
const CurseModpacksBrowserCreatorModal = lazy(() =>
import('./components/CurseModpacksBrowserCreatorModal/CurseModpacksBrowserCreatorModal')
);
const CurseModpackExplorerModal = lazy(() =>
import('./components/CurseModpackExplorerModal/CurseModpackExplorerModal')
);


type Props = {
location: object,
Expand Down Expand Up @@ -133,7 +139,13 @@ class RouteDef extends Component<Props> {
{isModal ? (
<Route
path="/curseModpackBrowserCreatorModal/:addonID"
component={CurseModpacksBrowserCreatorModal}
component={WaitingComponent(CurseModpacksBrowserCreatorModal)}
/>
) : null}
{isModal ? (
<Route
path="/curseModpackExplorerModal/:addonID"
component={WaitingComponent(CurseModpackExplorerModal)}
/>
) : null}
{isModal ? (
Expand Down
7 changes: 4 additions & 3 deletions app/utils/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import minimist from 'minimist';
import { exec } from 'child_process';
import log from 'electron-log';
import launchCommand from './MCLaunchCommand';
import store from '../localStore';

Expand All @@ -11,11 +12,11 @@ const parseCLI = async (data, callback) => {
await launchCommand(instanceName, auth),
(error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
log.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
log.log(`stdout: ${stdout}`);
log.log(`stderr: ${stderr}`);
}
);
start.on('exit', () => {
Expand Down
Loading

0 comments on commit 479d76c

Please sign in to comment.