Skip to content

Commit

Permalink
Merge pull request #374 from nudibranchrecords/release/v0.6.0-error-p…
Browse files Browse the repository at this point in the history
…opup-fix

Release/v0.6.0 error popup fix
  • Loading branch information
funwithtriangles authored Feb 21, 2020
2 parents e95714c + 6d87f3f commit aaf128f
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 64 deletions.
2 changes: 1 addition & 1 deletion example-projects/basic.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example-projects/fragment-shader.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example-projects/postprocessing.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example-projects/scenes.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion example-projects/sketches/postprocessing.json

This file was deleted.

2 changes: 1 addition & 1 deletion example-projects/text.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example-projects/trig.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions projectFixScripts/0.5-0.6.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const parseOldOptions = (key, node) => {
}

fix(data => {
// Loop through nodes in project
for (const key in data.nodes) {
const node = data.nodes[key]

Expand Down Expand Up @@ -58,6 +59,16 @@ fix(data => {
}
}

// Check if new core nodes are missing
if (data.nodes.areErrorPopupsDisabled === undefined) {
data.nodes.areErrorPopupsDisabled = {
title: 'Disable Error Popups',
id: 'areErrorPopupsDisabled',
valueType: 'boolean',
value: false,
}
}

return data
})

2 changes: 1 addition & 1 deletion projectFixScripts/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')

const args = process.argv.slice(2)
const inputPath = args[0]
const outputPath = './output'
const outputPath = args[1] || './output'
const fileName = path.basename(inputPath)

const fix = cb => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Col/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled from 'styled-components'

const Col = styled.div`
${props => props.width
${props => !props.noWidth && (props.width
? `flex: 0 0 ${props.width};`
: `flex: 1;`
: `flex: 1;`)
}
padding-right: 1rem;
Expand Down
21 changes: 21 additions & 0 deletions src/components/ErrorOverlay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import styled from 'styled-components'
import PropTypes from 'prop-types'
import OverlayModal from '../OverlayModal'
import Button from '../Button'
import Col from '../Col'
import Row from '../Row'
import Control from '../../containers/Control'

const ErrorMessage = styled.p`
opacity: 0.5;
Expand All @@ -16,11 +19,22 @@ const Wrapper = styled.div`
user-select: text;
`

const PopupControl = styled(Row)`
margin-top: 1rem;
font-size: 0.7rem;
background: rgba(100,100,100,0.5);
border-radius: 2px;
padding: 0.5rem;
text-align: left;
`

const ErrorOverlay = ({ isVisible, onCancelClick, code, message, onChooseSketchFolderClick }) => {
let inner = <p>Whoops!</p>
let showPopupControl = true

switch (code) {
case 'NO_SKETCH_FOLDER':
showPopupControl = false
inner = (
<Wrapper>
<p>The sketches folder for this project could not be located, please find the folder on your computer.
Expand All @@ -41,6 +55,13 @@ const ErrorOverlay = ({ isVisible, onCancelClick, code, message, onChooseSketchF
{inner}
<ErrorMessage>{message}</ErrorMessage>

{
showPopupControl && <PopupControl>
<Col width='2rem'><Control nodeId='areErrorPopupsDisabled' /></Col>
<Col noWidth>Stop errors from popping up (Can be enabled again in settings)</Col>
</PopupControl>
}

</OverlayModal>
)
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ const Settings = () => (
<Input name='throttledFPS' label='Throttled FPS' type='number' />
</Col>
</Row>
<h2>GUI</h2>
<Row>
<Col noWidth>
<p>Disable Error Popups</p>
</Col>
<Col width='1rem'>
<Control nodeId='areErrorPopupsDisabled' />
</Col>
</Row>
</form>
</Wrapper>
)
Expand Down
27 changes: 22 additions & 5 deletions src/externals/sketches.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const loadFile = resolvedPath => {
}

if (!file) {
throw new Error(`File not found: ${resolvedPath}`)
throw errcode(
new Error(`File not found: ${resolvedPath}`),
'FILE_NOT_FOUND',
{ forcePopup: true }
)
}

return file
Expand All @@ -45,7 +49,11 @@ const loadIndex = (file) => {

return loadFile(indexUrl)
} catch (error) {
throw new Error(`No index file found: ${error.message}`)
throw errcode(
new Error(`No index file found: ${error.message}`),
'SKETCH_INDEX_NOT_FOUND',
{ forcePopup: true }
)
}
}

Expand All @@ -56,7 +64,11 @@ const loadConfig = (file) => {

return loadFile(configUrl)
} catch (error) {
throw new Error(`No config file found: ${error.message}`)
throw errcode(
new Error(`No config file found: ${error.message}`),
'SKETCH_CONFIG_NOT_FOUND',
{ forcePopup: true }
)
}
}

Expand Down Expand Up @@ -98,7 +110,11 @@ const findSketches = (file, all, pathArray) => {
break
case 1:
// If only one file is missing (e.g. config but no index or index but no config)
throw new Error(`File not found: ${badFile}`)
throw errcode(
new Error(`File not found: ${badFile}`),
'FILE_NOT_FOUND',
{ forcePopup: true }
)
case 2:
// If both files are missing, keep looking at child folders
glob.sync(file + '/*').forEach(function (childFile) {
Expand All @@ -118,7 +134,8 @@ const loadSketches = globUrl => {
if (Object.keys(all).length === 0) {
throw errcode(
new Error('No sketches found in folder.'),
'NO_SKETCH_FOLDER'
'NO_SKETCH_FOLDER',
{ forcePopup: true }
)
}

Expand Down
4 changes: 3 additions & 1 deletion src/store/rootListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export default {
fileWatchListener(action, store)
await projectListener(action, store)
} catch (error) {
const state = store.getState()
const shouldPopup = !state.nodes.areErrorPopupsDisabled.value || error.forcePopup
console.error(error)
store.dispatch(projectError(error.message, { popup: true, code: error.code }))
store.dispatch(projectError(error.message, { popup: shouldPopup, code: error.code }))
}
},
}
102 changes: 53 additions & 49 deletions src/store/setCoreState.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,36 @@

import { uNodeCreate } from './nodes/actions'

export default store => {
store.dispatch(uNodeCreate('sceneCrossfader',
{
title: 'Scene Crossfader',
id: 'sceneCrossfader',
value: 0,
type: 'param',
valueType: 'float',
}
))

store.dispatch(uNodeCreate('viewerMode',
{
title: 'Viewer Mode',
valueType: 'enum',
id: 'viewerMode',
value: 'mix',
inputLinkIds: [],
options: [
{
value: 'mix',
label: 'Mix',
},
{
value: 'A',
label: 'A',
},
{
value: 'B',
label: 'B',
},
],
}
))

store.dispatch(uNodeCreate('sketchOrganization', {
const coreNodes = [
{
title: 'Scene Crossfader',
id: 'sceneCrossfader',
value: 0,
type: 'param',
valueType: 'float',
},
{
title: 'Viewer Mode',
valueType: 'enum',
id: 'viewerMode',
value: 'mix',
inputLinkIds: [],
options: [
{
value: 'mix',
label: 'Mix',
},
{
value: 'A',
label: 'A',
},
{
value: 'B',
label: 'B',
},
],
},
{
title: 'Sketch Organization',
valueType: 'enum',
value: 'folder',
Expand All @@ -58,44 +52,54 @@ export default store => {
label: 'Author',
},
],
}))

store.dispatch(uNodeCreate('audioLevelsFalloff', {
},
{
title: 'Disable Error Popups',
id: 'areErrorPopupsDisabled',
valueType: 'boolean',
value: false,
},
{
title: 'Levels Falloff',
type: 'param',
value: 1,
id: 'audioLevelsFalloff',
valueType: 'float',
}))
store.dispatch(uNodeCreate('audioLevelsPower', {
},
{
title: 'Levels Power',
type: 'param',
value: 0.25,
min: 0.5,
max: 3,
id: 'audioLevelsPower',
valueType: 'float',
}))
store.dispatch(uNodeCreate('audioLevelsSmoothing', {
},
{
title: 'Levels Smoothing',
type: 'param',
value: 0,
id: 'audioLevelsSmoothing',
valueType: 'float',
}))

store.dispatch(uNodeCreate('audioNormalizeLevels', {
},
{
title: 'Normalize Levels',
type: 'param',
value: 0.5,
id: 'audioNormalizeLevels',
valueType: 'float',
}))
store.dispatch(uNodeCreate('audioNormalizeRangeFalloff', {
},
{
title: 'Normalized Range Falloff',
type: 'param',
value: 0.01,
id: 'audioNormalizeRangeFalloff',
valueType: 'float',
}))
},
]

export default store => {
coreNodes.forEach(node => {
store.dispatch(uNodeCreate(node.id, node))
})
}

0 comments on commit aaf128f

Please sign in to comment.