Skip to content

Commit

Permalink
fix assets breaking compiling binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
omenking committed Jan 1, 2018
1 parent fa2b488 commit cd42f98
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
3 changes: 3 additions & 0 deletions app/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ input[type='submit'] {

.p0, .p1 { float: left; }

.settings_assets .buttons,
.settings_replay .buttons {
padding-top: 16px;
text-align: right;
}
.settings_assets .buttons .reveal,
.settings_assets .buttons .change,
.settings_replay .buttons .reveal,
.settings_replay .buttons .change{
margin-right: 8px;
Expand Down
26 changes: 7 additions & 19 deletions src/common/external_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,23 @@ export default class ExternalAssets {

// dir is reset to code defined path
case 'reset':
dir = path.join(app.getPath('appData'), 'swap-n-pop', 'external-assets')
dir = null
break;

// dir is set to last known if exists, otherwhise it resets
case '':
dir = store.has('asset-dir') ? store.get('asset-dir') : path.join(app.getPath('appData'), 'swap-n-pop', 'external-assets')
dir = store.has('asset-dir') ? store.get('asset-dir') : null
break;
}

console.log('reset',dir)
// set dir to newest defined
store.set('asset-dir', dir)
store.set('asset-dir', dir)

// create actual folder through dir if it doesnt exist
if (!fs.existsSync(dir))
fx.mkdirSync(dir);
if (dir !== null && !fs.existsSync(dir))
fx.mkdirSync(dir)

return dir;
}

public static list(callback) {
let dir = path.join(store.get('asset-dir'), '*.png')

glob(dir, {}, (err, files) => {
let filenames = []

for (let file of files)
filenames.push(path.basename(file, '.png'))

callback(err,filenames)
})
}
}
}
6 changes: 0 additions & 6 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ ipc.on('asset-dir-change', e => {
})
})

ipc.on('asset-list', e => {
ExternalAssets.list((err, files) => {
win.webContents.send('asset-list', files)
})
})

ipc.on('play-single', (event,data) => {
const seed = Replay.random_seed(16,undefined)
win.webContents.send('play-single',{
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/states/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import Store from 'common/store'

const store = new Store()

// load any external assets and store them in an scoped array
let external_assets = []
ipc.on('asset-list', (e, files) => external_assets = files)

/** Loads all sprites, spritesheets, sound effects, etc to the phaser game
* Uses signals to detect once everything has been loaded correctly
*/
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/ui/external_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function render() {
m('label', 'Asset Folder Location:'),
m('.input', asset_dir),
m('.buttons', [
m('.button.reveal', {onclick: () => ipc.send('asset-dir-reveal')}, 'Reveal'),
//m('.button.reveal', {onclick: () => ipc.send('asset-dir-reveal')}, 'Reveal'),
m('.button.change', {onclick: () => ipc.send('asset-dir-change')}, 'Change'),
m('.button.reset' , {onclick: () => ipc.send('asset-dir-reset')}, 'Reset'),
]),
Expand Down

0 comments on commit cd42f98

Please sign in to comment.