Skip to content

Commit

Permalink
feat: Polish to Curate
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Oct 10, 2019
1 parent 97ada07 commit 22629c8
Show file tree
Hide file tree
Showing 23 changed files with 249 additions and 122 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "extern/7zip-bin"]
path = extern/7zip-bin
url = https://github.com/develar/7zip-bin.git
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Install by running ``sudo apt install libgtk-3-0 libnss3``

## Development
Recommended setup for development:
1. Open a command prompt and run ``npm run build`` and wait for it to finish
2. In the same command prompt as before, run ``npm run watch`` and let the prompt stay open
1. Clone the repository with ``git clone --recurse-submodules https://github.com/FlashpointProject/launcher.git launcher``
2. In the new 'launcher' folder run ``npm run watch`` and let the prompt stay open
3. Open a second command prompt and run ``npm run start``

## Package Scripts
Expand Down
1 change: 1 addition & 0 deletions extern/7zip-bin
Submodule 7zip-bin added at 13c7b1
22 changes: 0 additions & 22 deletions extern/7zip/LICENSE.txt

This file was deleted.

Binary file removed extern/7zip/linux/arm/7za
Binary file not shown.
Binary file removed extern/7zip/linux/arm64/7za
Binary file not shown.
Binary file removed extern/7zip/linux/ia32/7za
Binary file not shown.
Binary file removed extern/7zip/linux/x64/7za
Binary file not shown.
9 changes: 0 additions & 9 deletions extern/7zip/linux/x64/build.sh

This file was deleted.

20 changes: 0 additions & 20 deletions extern/7zip/linux/x64/do-build.sh

This file was deleted.

Binary file removed extern/7zip/mac/7za
Binary file not shown.
Binary file removed extern/7zip/win/ia32/7za.exe
Binary file not shown.
Binary file removed extern/7zip/win/x64/7za.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ gulp.task('pack', (done) => {
fs.createFileSync(path.join(buildPath, '.installed'));
}
// Copy relevant 7za
fs.ensureDirSync(path.join(buildPath, 'extern/7zip'));
fs.ensureDirSync(path.join(buildPath, 'extern/7zip-bin'));
switch (platform) {
case 'darwin':
fs.copyFileSync('./extern/7zip/mac/7za', path.join(buildPath, 'extern/7zip/7za'));
fs.copyFileSync('./extern/7zip-bin/mac/7za', path.join(buildPath, 'extern/7zip-bin/7za'));
break;
case 'win32':
fs.copyFileSync(path.join(process.cwd(), 'extern/7zip/win', arch, '7za.exe'), path.join(buildPath, 'extern/7zip/7za.exe'));
fs.copyFileSync(path.join(process.cwd(), 'extern/7zip-bin/win', arch, '7za.exe'), path.join(buildPath, 'extern/7zip-bin/7za.exe'));
break;
case 'linux':
fs.copyFileSync(path.join(process.cwd(), 'extern/7zip/linux', arch, '7za'), path.join(buildPath, 'extern/7zip/7za'));
fs.copyFileSync(path.join(process.cwd(), 'extern/7zip-bin/linux', arch, '7za'), path.join(buildPath, 'extern/7zip-bin/7za'));
break;
}
// Copy Language folder
Expand Down
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"noNotes": "No Notes",
"originalDescription": "Original Description",
"noOriginalDescription": "No Original Description",
"additionalApplications": "Additional Application",
"additionalApplications": "Additional Applications",
"noName": "No Name",
"launch": "Launch",
"commandLine": "Command Line",
Expand Down Expand Up @@ -218,6 +218,8 @@
"noHeading": "No Heading",
"curationNotes": "Curation Notes",
"noCurationNotes": "No Curation Notes",
"newAddApp": "New App",
"removeAddApp": "Remove App",
"indexContent": "Update Content",
"remove": "Remove",
"removeCurationDesc": "Remove this curation (no changes will be made to any files)",
Expand Down
86 changes: 86 additions & 0 deletions licenses/7zip/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Copyright (C) 1999-2019 Igor Pavlov.

The licenses for files are:

1) 7z.dll:
- The "GNU LGPL" as main license for most of the code
- The "GNU LGPL" with "unRAR license restriction" for some code
- The "BSD 3-clause License" for some code
2) All other files: the "GNU LGPL".

Redistributions in binary form must reproduce related license information from this file.

Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/




BSD 3-clause License
--------------------

The "BSD 3-clause License" is used for the code in 7z.dll that implements LZFSE data decompression.
That code was derived from the code in the "LZFSE compression library" developed by Apple Inc,
that also uses the "BSD 3-clause License":

----
Copyright (c) 2015-2016, Apple Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----




unRAR license restriction
-------------------------

The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.

The license for original unRAR code has the following restriction:

The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.
62 changes: 25 additions & 37 deletions src/renderer/components/CurateBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import * as React from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { promisify } from 'util';
import { CurateLang, MiscLang } from '../../shared/lang/types';
import { get7zExec } from '../util/SevenZip';
import { CurationAction, EditCuration, EditCurationMeta } from '../context/CurationContext';
import { stringifyCurationFormat } from '../curate/format/stringifier';
import { importCuration, stringToBool } from '../curate/importCuration';
import { importCuration, launchCuration, stringToBool } from '../curate/importCuration';
import { CurationIndexContent } from '../curate/indexCuration';
import { convertEditToCurationMeta } from '../curate/metaToMeta';
import { getCurationFolder } from '../curate/util';
Expand All @@ -19,6 +18,7 @@ import { GameLauncher } from '../GameLauncher';
import { GameImageCollection } from '../image/GameImageCollection';
import { copyArrayLike, sizeToString } from '../Util';
import { LangContext } from '../util/lang';
import { get7zExec } from '../util/SevenZip';
import { GamePropSuggestions } from '../util/suggestions';
import { CheckBox } from './CheckBox';
import { ConfirmElement, ConfirmElementArgs } from './ConfirmElement';
Expand Down Expand Up @@ -130,36 +130,9 @@ export function CurateBox(props: CurateBoxProps) {
}
}, [props.dispatch, props.curation, props.games, props.gameImages]);
// Callback for testing a curation works
const onRunCuration = useCallback(async () => {
const onRun = useCallback(async () => {
if (props.curation) {
const curationPath = path.join(window.External.config.fullFlashpointPath, 'Curations', props.curation.key);
const serverPath = path.join(GameLauncher.getHtdocsPath(), 'content');
// Clear out old folder if exists
if (fs.existsSync(serverPath)) {
fs.removeSync(serverPath);
}
const contentPath = path.join(curationPath, 'content');
if (fs.existsSync(contentPath)) {
// Use symlinks on windows if running as Admin
if (process.platform === 'win32') {
exec('NET SESSION', (err,so,se) => {
if (se.length === 0) {
console.log('SYM');
fs.symlinkSync(contentPath, serverPath);
} else {
fs.copySync(contentPath, serverPath);
}
});
} else {
fs.copySync(contentPath, serverPath);
}
props.dispatch({
type: 'run-curation',
payload: {
key: props.curation.key
}
});
}
launchCuration(props.curation);
}
}, [props.dispatch, props.curation]);
// Callback for when the index content button is clicked
Expand All @@ -172,7 +145,7 @@ export function CurateBox(props: CurateBoxProps) {
}
});
}
}, [props.curation && props.curation.key, props.dispatch]);
}, [ props.dispatch, props.curation && props.curation.key]);
// Callback for when the open folder button is clicked
const onOpenFolder = useCallback(() => {
if (props.curation) {
Expand All @@ -188,6 +161,15 @@ export function CurateBox(props: CurateBoxProps) {
});
}
}, [props.dispatch, props.curation && props.curation.key]);
// Callback for when the new additional application button is clicked
const onNewAddApp = useCallback(() => {
if (props.curation) {
props.dispatch({
type: 'new-addapp',
payload: { key: props.curation.key }
});
}
}, [props.dispatch, props.curation && props.curation.key]);
// Callback for when the export button is clicked
const onExportClick = useCallback(() => {
if (props.curation) {
Expand Down Expand Up @@ -270,9 +252,10 @@ export function CurateBox(props: CurateBoxProps) {
const disabled = props.curation ? props.curation.locked : false;
// Render additional application elements
const addApps = useMemo(() => (
(props.curation && props.curation.addApps.length > 0) ? (
<>
{ strings.browse.additionalApplications }:
{ props.curation && props.curation.addApps.length > 0 ? (
<>
{ strings.browse.additionalApplications }:
{ props.curation.addApps.map(addApp => (
<CurateBoxAddApp
key={addApp.key}
Expand All @@ -282,9 +265,9 @@ export function CurateBox(props: CurateBoxProps) {
disabled={disabled}
onInputKeyDown={onInputKeyDown} />
)) }
<hr className='curate-box-divider' />
</>
) : undefined
) : undefined }
</>
), [
props.curation && props.curation.addApps,
props.curation && props.curation.key,
Expand Down Expand Up @@ -524,6 +507,11 @@ export function CurateBox(props: CurateBoxProps) {
{/* Additional Application */}
<div className='curate-box-add-apps'>
{addApps}
<SimpleButton
className='curate-box-buttons__button'
value={strings.curate.newAddApp}
onClick={onNewAddApp} />
<hr className='curate-box-divider' />
</div>
{/* Content */}
<div className='curate-box-files'>
Expand Down Expand Up @@ -559,7 +547,7 @@ export function CurateBox(props: CurateBoxProps) {
<SimpleButton
className='curate-box-buttons__button'
value={strings.curate.run}
onClick={onRunCuration} />
onClick={onRun} />
<SimpleButton
className='curate-box-buttons__button'
value={strings.curate.export}
Expand Down
23 changes: 23 additions & 0 deletions src/renderer/components/CurateBoxAddApp.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as React from 'react';
import { useCallback } from 'react';
import { CurationAction, EditAddAppCuration, EditAddAppCurationMeta } from '../context/CurationContext';
import { launchAddAppCuration } from '../curate/importCuration';
import { LangContext } from '../util/lang';
import { CurateBoxRow } from './CurateBoxRow';
import { InputField } from './InputField';
import { SimpleButton } from './SimpleButton';

export type CurateBoxAddAppProps = {
/** Key of the curation the displayed additional application belongs to. */
Expand All @@ -30,6 +32,19 @@ export function CurateBoxAddApp(props: CurateBoxAddAppProps) {
const disabled = props.disabled;
// Localized strings
const strings = React.useContext(LangContext);
// Callback for remove additional application button
const onRemove = useCallback(() => {
props.dispatch({
type: 'remove-addapp',
payload: {
curationKey: props.curationKey,
key: props.curation.key
}
});
}, [props.curationKey, props.curation.key, props.dispatch]);
const onRun = useCallback(() => {
launchAddAppCuration(props.curationKey, props.curation);
}, [props.curation && props.curation.meta && props.curationKey]);
// Render
return (
<div className='curate-box-add-app'>
Expand Down Expand Up @@ -60,6 +75,14 @@ export function CurateBoxAddApp(props: CurateBoxAddAppProps) {
disabled={disabled}
onKeyDown={props.onInputKeyDown} />
</CurateBoxRow>
<SimpleButton
className='curate-box-buttons__button'
value={strings.curate.removeAddApp}
onClick={onRemove} />
<SimpleButton
className='curate-box-buttons__button'
value={strings.curate.run}
onClick={onRun} />
</div>
);
}
Expand Down
Loading

0 comments on commit 22629c8

Please sign in to comment.