Skip to content

Commit e03ebb4

Browse files
committed
feature: new mapping autodismiss
1 parent baaf1a8 commit e03ebb4

File tree

9 files changed

+196
-79
lines changed

9 files changed

+196
-79
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- New mapping/DPLC engine
55
- Real custom mappings
66
- Sonic 2 Special Stage added [#21](/../../issues/21)
7+
- Sonic 3&K Sonic/Supersonic partial support
78
- New ASM parser/writer
89
- Added File menu
910
- Create new files / better file selection
@@ -13,6 +14,7 @@
1314
- Rebuilt Project screen
1415
- Tree structure for projects
1516
- Reuse file menu
17+
- New mapping autodismiss is configurable
1618
- Fixed a keycombination event bug [#29](/../../issues/29)
1719
- Fixed corrupted art when importing transparent PNGs [#22](/../../issues/22)
1820

TODO

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,37 @@ post image of project / some custom mappings, saying it's ready for testing
1010
BUFFER
1111
==
1212

13-
// rawBytes()
14-
// art ffset save message / input size
13+
art()
14+
mappings()
15+
dplcs()
16+
palettes()
17+
18+
definition([
19+
many(art()),
20+
])
21+
1522
// copy to project
16-
// autodismiss
1723
// autozoom based on sprite size for sprites tab
1824

19-
// reverse endianness
20-
// new mapping screen always show
25+
// art ffset save message / input size
26+
// crackers first, then kd cham
27+
// UI by definition
2128

22-
// other
29+
// reverse endianness
30+
// rawBytes()
2331

24-
// need an external scrtipts folder copied to the root on bundle
25-
// example: HUD graphics
32+
// go back to qiuu with questions
2633

2734
// formats to support
2835

2936
// kid chameleon
3037
// crackers
3138
// chaotix
3239
// s3k sonic saving
33-
// streets of rage
3440
// plane mappings / snap to
41+
// ristar
3542
// github issues
36-
/* https://github.com/Ralakimus/sonic-cd-r11a-disassembly */
43+
/* https://raw.githubusercontent.com/Dandaman955/Streets-of-Rage-1-Disassembly-Redux/master/SoR.asm */
3744
/* http://info.sonicretro.org/Disassemblies */
3845

3946
ROADMAP
@@ -55,16 +62,8 @@ import history - many writes while drawing
5562

5663
FEATURES
5764
set colour of art tiles
58-
radio button
5965
make decompression threaded
6066
ctrl+wheel for horiz scroll
61-
62-
PROJECTS
63-
copy object
64-
65-
NEW MAPPING
66-
add checkbox to the modal (autodismiss [x])
67-
6867
==
6968
ROTSPRITE
7069
rotsprite https://crates.io/crates/rotsprite
Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React, { Component } from 'react';
22
import chunk from 'lodash/chunk';
3-
import { select, event, mouse } from 'd3-selection';
3+
import { select, mouse } from 'd3-selection';
44
import { drag } from 'd3-drag';
55
import { mappingState } from './state';
66
import { environment } from '#store/environment';
77
import { observer } from 'mobx-react';
88
import { Mapping } from './mapping';
99
import { Spring } from 'react-spring/renderprops';
10+
import { Checkbox } from '#ui';
1011

1112
const baseConfig = {
1213
hflip: false,
@@ -18,90 +19,109 @@ const baseConfig = {
1819
};
1920

2021

22+
const AutoDismiss = observer(() => (
23+
<div className="autodismiss">
24+
<span onClick={mappingState.toggleAutodismiss}>autodismiss</span>
25+
<Checkbox
26+
checked={mappingState.autodismiss}
27+
onChange={mappingState.toggleAutodismiss}
28+
/>
29+
</div>
30+
));
31+
2132
@observer
2233
export class NewMapping extends Component {
23-
2434
onRef = (node) => {
2535
this.node = node;
26-
}
36+
};
2737

2838
pos = [void 0, void 0];
2939
mapDefz = [];
3040

3141
dragPlacementFactory = (index) => {
3242
return (node) => {
3343
if (node) {
34-
select(node).call(drag().filter(() => true)
44+
select(node).call(
45+
drag()
46+
.filter(() => true)
3547
.on('start', () => {
3648
const { newMapping, scale } = mappingState;
37-
const [x, y] = this.pos = mouse(this.node);
49+
const [x, y] = (this.pos = mouse(this.node));
3850
const [pieceX, pieceY] = mouse(node);
3951

4052
newMapping.piece = Object.assign(
4153
{},
4254
this.mapDefz[index],
4355
{
44-
top: (y/scale) - (pieceY/4)|0,
45-
left: (x/scale) - (pieceX/4)|0,
56+
top: (y / scale - pieceY / 4) | 0,
57+
left: (x / scale - pieceX / 4) | 0,
4658
},
4759
);
48-
4960
})
5061
.on('drag', () => {
51-
const { newMapping: { piece }, scale } = mappingState;
62+
const {
63+
newMapping: { piece },
64+
scale,
65+
} = mappingState;
5266
const [x, y] = mouse(this.node);
53-
const [dx, dy] = [x-this.pos[0], y-this.pos[1]];
67+
const [dx, dy] = [x - this.pos[0], y - this.pos[1]];
5468
this.pos = [x, y];
5569

56-
Object.assign(
57-
piece,
58-
{
59-
top: piece.top + (dy/scale),
60-
left: piece.left + (dx/scale),
61-
},
62-
);
70+
Object.assign(piece, {
71+
top: piece.top + dy / scale,
72+
left: piece.left + dx / scale,
73+
});
6374
})
6475
.on('end', () => {
6576
mappingState.placeNewMapping();
66-
})
77+
}),
6778
);
68-
6979
}
7080
};
7181
};
7282

7383
getLeft = () => {
74-
const { newMapping: { active, piece } } = mappingState;
75-
if (active && piece || !active) return -325;
84+
const {
85+
newMapping: { active, piece },
86+
} = mappingState;
87+
if ((active && piece) || !active) return -325;
7688
else if (active) return 15;
7789
};
7890

7991
getOpacity = () => {
80-
const { newMapping: { active } } = mappingState;
92+
const {
93+
newMapping: { active },
94+
} = mappingState;
8195
return active ? 1 : 0;
8296
};
8397

8498
render() {
85-
const { tiles, config: { currentTile } } = environment;
86-
const { scale, newMapping: { active, piece } } = mappingState;
87-
88-
this.mapDefz = Array.from({length: 0x10}, (_, i) => ({
99+
const {
100+
tiles,
101+
config: { currentTile },
102+
} = environment;
103+
const {
104+
scale,
105+
newMapping: { active, piece },
106+
} = mappingState;
107+
108+
this.mapDefz = Array.from({ length: 0x10 }, (_, i) => ({
89109
art: currentTile,
90-
width: (i%4)+1,
91-
height: 0|(i/4)+1,
110+
width: (i % 4) + 1,
111+
height: 0 | (i / 4 + 1),
92112
...baseConfig,
93113
}));
94114

95115
return (
96116
<div ref={this.onRef}>
97117
{piece && (
98-
<div className="new-floating-piece">
99-
<Mapping
100-
data={piece}
101-
scale={mappingState.scale}
102-
tileBuffer={tiles}
118+
<div className="new-floating-piece">
119+
<Mapping
120+
data={piece}
121+
scale={mappingState.scale}
122+
tileBuffer={tiles}
103123
/>
104-
</div>
124+
</div>
105125
)}
106126
<Spring
107127
from={{
@@ -113,34 +133,34 @@ export class NewMapping extends Component {
113133
opacity: this.getOpacity(),
114134
}}
115135
>
116-
{({left, opacity}) => (
117-
<div
118-
className="new-mapping"
119-
style={{ left, opacity }}
120-
>
121-
{opacity > .01 &&
122-
chunk(this.mapDefz, 4).map((group, gIndex) => (
123-
<div key={gIndex} className="group">
124-
{group.map((def, lineIndex) => {
125-
const index = (gIndex * 4) + lineIndex;
126-
const dragPlacement = this.dragPlacementFactory(index);
127-
return <Mapping
128-
key={index}
129-
wrapRef={dragPlacement}
130-
data={def}
131-
scale={4}
132-
tileBuffer={tiles}
133-
/>;
134-
})}
135-
</div>
136-
)
137-
)}
138-
TODO: autodismiss
136+
{({ left, opacity }) => (
137+
<div className="new-mapping" style={{ left, opacity }}>
138+
{opacity > 0.01 &&
139+
chunk(this.mapDefz, 4).map((group, gIndex) => (
140+
<div key={gIndex} className="group">
141+
{group.map((def, lineIndex) => {
142+
const index =
143+
gIndex * 4 + lineIndex;
144+
const dragPlacement = this.dragPlacementFactory(
145+
index,
146+
);
147+
return (
148+
<Mapping
149+
key={index}
150+
wrapRef={dragPlacement}
151+
data={def}
152+
scale={4}
153+
tileBuffer={tiles}
154+
/>
155+
);
156+
})}
157+
</div>
158+
))}
159+
<AutoDismiss />
139160
</div>
140161
)}
141162
</Spring>
142163
</div>
143164
);
144165
}
145-
146166
}

app/components/mappings/state/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { optimizeCurrentDPLCs } from './optimize-dplcs';
77
import { deleteUnusedTiles } from './delete-unused-tiles';
88
import { toggleDPLCs } from './toggle-dplcs';
99
import { arrangeTilesBySpriteOrder } from './arrange-tiles-by-sprite-order';
10+
import { storage } from '#store/storage';
1011

1112
class MappingState {
1213

@@ -131,6 +132,12 @@ class MappingState {
131132
piece: void 0,
132133
};
133134

135+
@observable autodismiss = true;
136+
137+
@action toggleAutodismiss = () => {
138+
this.autodismiss = !this.autodismiss
139+
};
140+
134141
@action placeNewMapping = placeNewMapping;
135142

136143
// active mappings
@@ -170,4 +177,5 @@ class MappingState {
170177
}
171178

172179
const mappingState = new MappingState();
180+
storage(mappingState, 'mapping-state', ['autodismiss']);
173181
export { mappingState };

app/components/mappings/state/place-new-mapping.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export function placeNewMapping() {
3131
);
3232
environment.config.currentTile += piece.width * piece.height;
3333
mappingState.newMapping.piece = void 0;
34-
mappingState.newMapping.active = false;
34+
if (mappingState.autodismiss) {
35+
mappingState.newMapping.active = false;
36+
}
3537
mappingState.optimizeCurrentDPLCs();
3638
}

app/formats/scripts/run-script.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ function makeOffsetTable({ read, write }) {
5252
return (size = constants.dc.w, { items } = {}) => [
5353
({ getCursor }) => ({ ref }) => {
5454
const cursor = getCursor();
55+
const mask = (2 ** (size - 1)) - 1; // 0x7FFF for dc.w
5556
if (!ref.global.ptr) {
56-
ref.global.ptr = 0x7FFF;
57+
ref.global.ptr = mask;
5758
}
5859
const headers = [];
5960
// we keep searching for headers until either;
6061
// - cursor reaches a header pointer value
6162
// - items is exceeded
6263
for (let i = cursor; i < 1e5 && i < ref.global.ptr; i = getCursor()) {
63-
const header = (read(size) & 0x7FFF) + cursor;
64+
const header = (read(size) & mask) + cursor;
6465
headers.push(header);
6566
logger('= HEADER =', header);
6667
if (header < ref.global.ptr && !(header === 0)) {

development/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ electron-packager ./static Flex2 --platform=linux --arch=x64 --asar --overwrite
1818
electron-packager ./static Flex2 --platform=darwin --arch=x64 --asar --overwrite --package-manager yarn
1919

2020

21+
cp -r scripts Flex2-win32-ia32
2122
cd Flex2-win32-ia32
2223
zip -r ../flex2-win32-ia32.zip *
2324
cd ..
2425
rm -r Flex2-win32-ia32
2526

27+
cp -r scripts Flex2-win32-x64
2628
cd Flex2-win32-x64
2729
zip -r ../flex2-win32-x64.zip *
2830
cd ..
2931
rm -r Flex2-win32-x64
3032

33+
cp -r scripts Flex2-linux-x64
3134
cd Flex2-linux-x64
3235
chmod a+x Flex2
3336
tar cfvz ../flex2-linux-x64.tar.gz *
3437
cd ..
3538
rm -r Flex2-linux-x64
3639

40+
cp -r scripts Flex2-darwin-x64
3741
cd Flex2-darwin-x64
3842
chmod a+x Flex2
3943
tar cfvz ../flex2-osx-x64.tar.gz *

0 commit comments

Comments
 (0)