poi-plugin-compass 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/compass.css +16 -0
- package/index.js +35 -13
- package/package.json +2 -2
package/assets/compass.css
CHANGED
|
@@ -220,6 +220,7 @@
|
|
|
220
220
|
|
|
221
221
|
.compass-edge {
|
|
222
222
|
outline: none;
|
|
223
|
+
cursor: pointer;
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
.compass-edge line {
|
|
@@ -275,12 +276,27 @@
|
|
|
275
276
|
cursor: pointer;
|
|
276
277
|
}
|
|
277
278
|
|
|
279
|
+
.compass-edge.is-selected line,
|
|
280
|
+
.compass-edge:hover line,
|
|
281
|
+
.compass-edge:focus line,
|
|
278
282
|
.compass-edge.is-manual-choice:hover line,
|
|
279
283
|
.compass-edge.is-manual-choice:focus line {
|
|
280
284
|
stroke: #f4d476;
|
|
281
285
|
stroke-width: 8;
|
|
282
286
|
}
|
|
283
287
|
|
|
288
|
+
.compass-edge-id-label {
|
|
289
|
+
fill: #ffffff;
|
|
290
|
+
font-size: 14px;
|
|
291
|
+
font-weight: 800;
|
|
292
|
+
text-anchor: middle;
|
|
293
|
+
paint-order: stroke;
|
|
294
|
+
stroke: #151a22;
|
|
295
|
+
stroke-width: 4px;
|
|
296
|
+
stroke-linejoin: round;
|
|
297
|
+
pointer-events: none;
|
|
298
|
+
}
|
|
299
|
+
|
|
284
300
|
.compass-edge-label {
|
|
285
301
|
fill: #e2e8f0;
|
|
286
302
|
font-size: 18px;
|
package/index.js
CHANGED
|
@@ -496,6 +496,7 @@ class Compass extends React.Component {
|
|
|
496
496
|
: mapIds[0],
|
|
497
497
|
phaseId: phaseOptionsForMap(mapIds[0])[0]?.id || null,
|
|
498
498
|
selectedNode: pluginState.currentNode || null,
|
|
499
|
+
selectedEdge: null,
|
|
499
500
|
overrides: {},
|
|
500
501
|
exportOpen: false,
|
|
501
502
|
exportRoute: null,
|
|
@@ -535,6 +536,7 @@ class Compass extends React.Component {
|
|
|
535
536
|
mapId,
|
|
536
537
|
phaseId: phaseOptionsForMap(mapId)[0]?.id || null,
|
|
537
538
|
selectedNode: null,
|
|
539
|
+
selectedEdge: null,
|
|
538
540
|
overrides: {},
|
|
539
541
|
exportRoute: null,
|
|
540
542
|
exportEnemies: {},
|
|
@@ -582,15 +584,15 @@ class Compass extends React.Component {
|
|
|
582
584
|
}
|
|
583
585
|
|
|
584
586
|
selectPhase(phaseId) {
|
|
585
|
-
this.setState({ phaseId, selectedNode: null, overrides: {}, exportRoute: null, exportEnemies: {}, exportFormations: {}, exportError: null })
|
|
587
|
+
this.setState({ phaseId, selectedNode: null, selectedEdge: null, overrides: {}, exportRoute: null, exportEnemies: {}, exportFormations: {}, exportError: null })
|
|
586
588
|
}
|
|
587
589
|
|
|
588
590
|
selectNode(node) {
|
|
589
|
-
this.setState({ selectedNode: node })
|
|
591
|
+
this.setState({ selectedNode: node, selectedEdge: null })
|
|
590
592
|
}
|
|
591
593
|
|
|
592
594
|
selectFleet(deckId) {
|
|
593
|
-
this.setState({ deckId, selectedNode: null, overrides: {}, exportRoute: null, exportEnemies: {}, exportFormations: {}, exportError: null })
|
|
595
|
+
this.setState({ deckId, selectedNode: null, selectedEdge: null, overrides: {}, exportRoute: null, exportEnemies: {}, exportFormations: {}, exportError: null })
|
|
594
596
|
}
|
|
595
597
|
|
|
596
598
|
renderLosIcons(scores) {
|
|
@@ -611,15 +613,20 @@ class Compass extends React.Component {
|
|
|
611
613
|
`制空 ${air.min === air.max ? air.min : `${air.min}~${air.max}`}`)
|
|
612
614
|
}
|
|
613
615
|
|
|
614
|
-
setManualOverride(node, to) {
|
|
616
|
+
setManualOverride(node, to, edgeId = null) {
|
|
615
617
|
this.setState((state) => ({
|
|
616
618
|
overrides: { ...state.overrides, [node]: to },
|
|
617
619
|
selectedNode: node,
|
|
620
|
+
selectedEdge: edgeId,
|
|
618
621
|
exportRoute: null,
|
|
619
622
|
exportError: null,
|
|
620
623
|
}))
|
|
621
624
|
}
|
|
622
625
|
|
|
626
|
+
selectEdge(edgeId) {
|
|
627
|
+
this.setState({ selectedEdge: edgeId })
|
|
628
|
+
}
|
|
629
|
+
|
|
623
630
|
renderMap(mapDefinition, geometry, evaluation, selectedNode, currentNode, passedNodes = [], mapId = null) {
|
|
624
631
|
if (!mapGeometryAvailable(mapDefinition, geometry)) {
|
|
625
632
|
return h('div', { className: 'compass-empty-panel' }, 'poi 地图数据不可用')
|
|
@@ -658,6 +665,7 @@ class Compass extends React.Component {
|
|
|
658
665
|
|| []
|
|
659
666
|
const manualChoice = evaluation.decisions[edge.from]?.manual
|
|
660
667
|
&& manualOutcomes.some((outcome) => outcome.to === edge.to)
|
|
668
|
+
const selected = this.state.selectedEdge === edge.cell
|
|
661
669
|
const edgeClassNames = [
|
|
662
670
|
'compass-edge',
|
|
663
671
|
probability.global != null ? 'is-reachable' : '',
|
|
@@ -665,21 +673,33 @@ class Compass extends React.Component {
|
|
|
665
673
|
probabilityTier(probability.global),
|
|
666
674
|
passedEdges.has(`${edge.from}->${edge.to}`) ? 'is-passed' : '',
|
|
667
675
|
manualChoice ? 'is-manual-choice' : '',
|
|
676
|
+
selected ? 'is-selected' : '',
|
|
668
677
|
].filter(Boolean).join(' ')
|
|
669
678
|
const activateEdge = (event) => {
|
|
670
679
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
671
680
|
event.preventDefault()
|
|
672
|
-
this.setManualOverride(edge.from, edge.to)
|
|
681
|
+
if (manualChoice) this.setManualOverride(edge.from, edge.to, edge.cell)
|
|
682
|
+
else this.selectEdge(edge.cell)
|
|
673
683
|
}
|
|
674
684
|
}
|
|
675
685
|
return h('g', {
|
|
676
686
|
key: `edge-${edge.cell}`,
|
|
677
687
|
className: edgeClassNames,
|
|
678
|
-
role:
|
|
679
|
-
tabIndex:
|
|
680
|
-
|
|
681
|
-
|
|
688
|
+
role: 'button',
|
|
689
|
+
tabIndex: 0,
|
|
690
|
+
'aria-label': `边 ID ${edge.cell}:${edge.from}→${edge.to}`,
|
|
691
|
+
onClick: () => manualChoice
|
|
692
|
+
? this.setManualOverride(edge.from, edge.to, edge.cell)
|
|
693
|
+
: this.selectEdge(edge.cell),
|
|
694
|
+
onKeyDown: activateEdge,
|
|
682
695
|
},
|
|
696
|
+
h('title', null, [
|
|
697
|
+
`边 ID ${edge.cell}:${edge.from} → ${edge.to}`,
|
|
698
|
+
manualChoice ? '点击选择方向' : null,
|
|
699
|
+
probability.global != null && Number(probability.global) > 0
|
|
700
|
+
? `局部 ${formatPercent(probability.local, probability.estimated)}`
|
|
701
|
+
: null,
|
|
702
|
+
].filter(Boolean).join(' · ')),
|
|
683
703
|
h('line', {
|
|
684
704
|
x1: from.x,
|
|
685
705
|
y1: from.y,
|
|
@@ -694,10 +714,12 @@ class Compass extends React.Component {
|
|
|
694
714
|
className: 'compass-edge-label',
|
|
695
715
|
}, formatPercent(probability.global, probability.estimated))
|
|
696
716
|
: null,
|
|
697
|
-
|
|
698
|
-
? h('
|
|
699
|
-
|
|
700
|
-
:
|
|
717
|
+
selected
|
|
718
|
+
? h('text', {
|
|
719
|
+
x: (from.x + to.x) / 2,
|
|
720
|
+
y: (from.y + to.y) / 2 - 18,
|
|
721
|
+
className: 'compass-edge-id-label',
|
|
722
|
+
}, `ID ${edge.cell}`)
|
|
701
723
|
: null,
|
|
702
724
|
)
|
|
703
725
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-compass",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "通常海域舰队罗盘",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"icon": "fa/compass",
|
|
53
53
|
"priority": 20,
|
|
54
54
|
"apiVer": {
|
|
55
|
-
"11.99.99": "0.1.
|
|
55
|
+
"11.99.99": "0.1.2"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|