Skip to content

Commit d7926ce

Browse files
committed
Added file tab, started working on definition file loading
1 parent 060ad9c commit d7926ce

11 files changed

Lines changed: 104 additions & 55 deletions

File tree

TODO

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ many writes while drawing
1616
project files easier to use / create
1717
sprites are offset if something else lods fullscreen
1818
FEATURES
19+
make decompression threaded
1920
ctrl+wheel for horiz scroll
2021
fullscreen icons - https://systemuicons.com/ arrows
2122
TASKS
2223
checkbox
2324
buffer is deprecated on save
2425
==
2526
CUSTOM FORMATS
26-
specify mapping definition files or presets
27-
disable optimizations
2827
==
2928
ROTSPRITE
3029
https://forums.sonicretro.org/index.php?threads/sprite-rotation-utility.8848/#post-159754

app/components/file/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { useEffect, useState, useRef } from 'react';
2+
import { observer } from 'mobx-react';
3+
import { Item, Input, File as FileInput, Select, Editor } from '#ui';
4+
import { scriptListing } from '#formats/scripts';
5+
// console.log(require('electron').remote.app.getAppPath())
6+
// const chokidar = require('chokidar');
7+
8+
// chokidar.watch('./scripts').on('all', console.log)
9+
10+
// just load scripts from dropdown
11+
12+
export const File = observer(() => {
13+
14+
useEffect(() => {
15+
16+
17+
}, []);
18+
return <div>
19+
left align
20+
<FileInput />
21+
{JSON.stringify(scriptListing())}
22+
</div>;
23+
});

app/components/layout/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { model, saveModel } from './model';
44
import FlexLayout from 'flexlayout-react';
55
import classNames from 'classnames';
66

7+
import { File } from '#components/file';
78
import { Project } from '#components/project';
89
import { Palettes } from '#components/palettes';
910
import { Art } from '#components/art/index';
@@ -14,7 +15,9 @@ import { Documentation } from '#components/documentation';
1415
const getPanel = (node) => {
1516
const component = node.getComponent();
1617
if (!node._visible) return false;
17-
if (component === 'project') {
18+
if (component === 'file') {
19+
return <File node={node}/>;
20+
} else if (component === 'project') {
1821
return <Project node={node}/>;
1922
} else if (component === 'palettes') {
2023
return <Palettes node={node}/>;

app/components/layout/model.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import FlexLayout from 'flexlayout-react';
22

3+
let fileMenu;
4+
35
const DEFAULT_LAYOUT = {
46
'global': {
57
'splitterSize': 6,
@@ -36,6 +38,12 @@ const DEFAULT_LAYOUT = {
3638
'selected': 0,
3739
'id': '#2',
3840
'children': [
41+
fileMenu = {
42+
'type': 'tab',
43+
'name': 'File',
44+
'component': 'file',
45+
'id': '#11',
46+
},
3947
{
4048
'type': 'tab',
4149
'name': 'Project',
@@ -74,10 +82,26 @@ const DEFAULT_LAYOUT = {
7482
},
7583
};
7684

85+
const recurse = (children, callback) => {
86+
children.forEach(child => {
87+
callback(child, children);
88+
if (child.children) {
89+
recurse(child.children, callback);
90+
}
91+
});
92+
};
93+
7794
const migrations = [
7895
(layout) => {
7996
layout.global.tabSetEnableMaximize = true;
8097
},
98+
(layout) => {
99+
recurse([layout.layout], (node, parent) => {
100+
if (node.component === 'project') {
101+
parent.unshift(fileMenu);
102+
}
103+
});
104+
},
81105
];
82106

83107
let savedLayout = localStorage.getItem('layout');
@@ -91,7 +115,7 @@ if (savedLayout && version < migrations.length) {
91115
migrations
92116
.slice(version)
93117
.forEach((migration, i) => {
94-
console.info(`Layout migration #${i}`);
118+
console.info(`Layout migration #${i + version}`);
95119
migration(layout);
96120
version++;
97121
});

app/components/palettes/picker.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ export const Sketch = ({
212212
shadow:
213213
'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)',
214214
},
215+
circle: {
216+
width: '4px',
217+
height: '4px',
218+
boxShadow: `0 0 0 1.5px ${(rgb.r+rgb.b+rgb.g) < 384 ? white : black}, inset 0 0 1px 1px rgba(0,0,0,.3),
219+
0 0 1px 2px rgba(0,0,0,.4)`,
220+
borderRadius: '50%',
221+
cursor: 'hand',
222+
transform: 'translate(-2px, -2px)',
223+
},
215224
},
216225
});
217226

@@ -223,6 +232,9 @@ export const Sketch = ({
223232
hsl={hsl}
224233
hsv={hsv}
225234
onChange={onChange}
235+
pointer={() => (
236+
<div style={styles.circle} />
237+
)}
226238
/>
227239
</div>
228240
<div style={styles.controls} className="flexbox-fix">

app/components/project/object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { compressionFormats } from '#formats/compression';
77
const compressionList = Object.keys(compressionFormats);
88
const mappingList = [...Object.keys(mappingFormats), 'Custom'];
99
const dplcList = [...Object.keys(dplcFormats), 'Custom'];
10-
const paletteLengths = '1234'.split``.map((d) => ({label: d, value: +d}));
10+
const paletteLengths = [...'1234'].map((d) => ({label: d, value: +d}));
1111

1212
@observer
1313
export class ObjectConfig extends Component {

app/formats/scripts/index.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
import fs from 'fs';
2+
import { join, dirname } from 'path';
3+
import { errorMsg } from '#util/dialog';
4+
import { uniq } from 'lodash';
5+
6+
// if it can't find it, ask to specify
7+
8+
const scriptPaths = uniq([
9+
process.cwd(),
10+
dirname(process.execPath),
11+
]).map(path => join(path, 'scripts2'));
12+
13+
const scriptDir = scriptPaths.find(path => fs.existsSync(path));
14+
15+
if (!scriptDir) {
16+
errorMsg(`Script Error`, `
17+
Could not find 'scripts' directory for mapping definition files
18+
Searched in;
19+
\t${scriptPaths.join('\n\t')}`);
20+
}
21+
22+
export async function scriptListing() {
23+
// readdirSync(scriptDir)
24+
// console.log(await readdir(scriptDir))
25+
}
26+
27+
// function scriptDir() {
28+
29+
// }
30+
131
// next: file menu + custom loader -> remove brace
232
//
333
// script language
@@ -30,7 +60,7 @@
3060
// ability to specify offset & etc
3161
// allow editing filename
3262
// format:
33-
// add to project
63+
// add conf to project
3464
// remove acdeditor
3565
// purple warning: arbitrary code - warning before yes
3666
// derive UI from script - make dplcs still optional

app/store/environment.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ autorun(() => {
261261
// force currentSprite to lie within bounds
262262
if (config.currentSprite < 0 || mappings.length == 0) {
263263
config.currentSprite = 0;
264-
}
265-
else if (config.currentSprite >= mappings.length) {
264+
} else if (config.currentSprite >= mappings.length) {
266265
config.currentSprite = mappings.length -1;
267266
}
268267
});

app/store/storage.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { autorun } from 'mobx';
2-
import debounce from 'lodash/debounce';
3-
41
let saveData = true;
52

63
export function storage(obj, name) {
@@ -24,16 +21,11 @@ export function storage(obj, name) {
2421
obj[prop] = saved[prop];
2522
}
2623
});
27-
}
28-
catch(e) {
24+
} catch(e) {
2925
console.error(`Error parsing localStorage JSON data: ${e}`);
3026
}
3127
}
3228

33-
// save during editing
34-
// const save = debounce((data) => { localStorage.setItem(name, data); }, 1000);
35-
// autorun(() => { save(JSON.stringify(obj)); });
36-
3729
// save on close
3830
window.addEventListener('beforeunload', () => {
3931
if (saveData) {

app/util/async-render.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)