Skip to content

Commit 2bc37dd

Browse files
committed
Made isASM computed
1 parent 95137e7 commit 2bc37dd

5 files changed

Lines changed: 26 additions & 20 deletions

File tree

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ custom mapping formats / screen mappings
55
export spritesheet
66
rotsprite
77
animation editor
8+
spritesmind
89
==
910
BUGS
1011
show/hide collapse config state

app/components/file/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ import { Item, Input, File as FileInput, Select, Editor } from '#ui';
44
import { listing, load } from '#formats/scripts';
55

66
export const File = observer(() => {
7-
87
// useEffect(() => {
98

10-
119
// }, []);
1210
if (listing.length) {
1311
console.log('script');
14-
load(listing[0].value);
12+
// load(listing[0].value);
1513
}
16-
return <div>
17-
left align
18-
<FileInput />
19-
{JSON.stringify(listing)}
20-
</div>;
14+
return (
15+
<div>
16+
left align
17+
<FileInput />
18+
{JSON.stringify(listing)}
19+
</div>
20+
);
2121
});
22+
23+
// make fileinput allowed to edit text

app/components/import/color-match.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ function nearestColor(line = 0) {
1717

1818
if (preCalculated) {
1919
return preCalculated.result;
20-
}
21-
else {
20+
} else {
2221
const result = closest(color, palette);
2322

2423
cache.push({color, result});

app/store/environment.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { readFileSync, writeFileSync } from 'fs';
2-
import { extname } from 'path';
32
import { observable, computed, action, autorun } from 'mobx';
43
import range from 'lodash/range';
54
import unique from 'lodash/uniq';
@@ -114,11 +113,10 @@ class Environment {
114113
// load mappings
115114
if (obj.mappings.path) {
116115
const mappingPath = workspace.absolutePath(obj.mappings.path);
117-
const isAsm = extname(obj.mappings.path) == '.asm';
118116
try {
119117
const buffer = readFileSync(mappingPath);
120118
const newMappings = bufferToMappings(
121-
isAsm ? asmToBin(buffer) : buffer,
119+
obj.mappingsASM ? asmToBin(buffer) : buffer,
122120
obj.mappingDefinition,
123121
);
124122
this.mappings.replace(newMappings);
@@ -134,11 +132,10 @@ class Environment {
134132
this.config.dplcsEnabled = obj.dplcs.enabled == true && obj.dplcs.path;
135133
if (this.config.dplcsEnabled && obj.dplcs.path) {
136134
const dplcPath = workspace.absolutePath(obj.dplcs.path);
137-
const isAsm = extname(obj.dplcs.path) == '.asm';
138135
try {
139136
const buffer = readFileSync(dplcPath);
140137
const newDPLCs = bufferToDPLCs(
141-
isAsm ? asmToBin(buffer) : buffer,
138+
obj.dplcsASM ? asmToBin(buffer) : buffer,
142139
obj.dplcDefinition,
143140
);
144141
this.dplcs.replace(newDPLCs);
@@ -200,10 +197,9 @@ class Environment {
200197
// mappings
201198
if (obj.mappings.path) {
202199
const mappingPath = workspace.absolutePath(obj.mappings.path);
203-
const isAsm = extname(obj.mappings.path) == '.asm';
204200

205201
const { chunk, frames } = mappingsToBuffer(this.mappings, obj.mappingDefinition);
206-
const out = isAsm ? stuffToAsm(frames, obj.mappings.label, true) : chunk;
202+
const out = obj.mappingsASM ? stuffToAsm(frames, obj.mappings.label, true) : chunk;
207203
try {
208204
writeFileSync(mappingPath, out);
209205
}
@@ -215,10 +211,9 @@ class Environment {
215211
// dplcs
216212
if (obj.dplcs.enabled && obj.dplcs.path) {
217213
const dplcPath = workspace.absolutePath(obj.dplcs.path);
218-
const isAsm = extname(obj.dplcs.path) == '.asm';
219214

220215
const { chunk, frames } = DPLCsToBuffer(this.dplcs, obj.dplcDefinition);
221-
const out = isAsm ? stuffToAsm(frames, obj.dplcs.label) : chunk;
216+
const out = obj.dplcsASM ? stuffToAsm(frames, obj.dplcs.label) : chunk;
222217
try {
223218
writeFileSync(dplcPath, out);
224219
}

app/store/objectdef.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { observable, computed, action, autorun, toJS } from 'mobx';
1+
import { observable, computed, action } from 'mobx';
22
import { environment } from '#store/environment';
33
import { mappingFormats, dplcFormats } from '#formats/definitions';
4+
import { extname } from 'path';
45

56
export class ObjectDef {
67

@@ -24,6 +25,14 @@ export class ObjectDef {
2425
label: '',
2526
};
2627

28+
@computed get mappingsASM() {
29+
return extname(this.mappings.path) === '.asm';
30+
}
31+
32+
@computed get dplcsASM() {
33+
return extname(this.dplcs.path) === '.asm';
34+
}
35+
2736
@computed get key() {
2837
return Math.random().toString(35).slice(2);
2938
}

0 commit comments

Comments
 (0)