Fix various issues that made the walkthrough non-completable

This commit is contained in:
Quincy Morgan
2020-05-07 13:27:20 -07:00
parent 4478dba08d
commit ff4eb971ac
6 changed files with 31 additions and 35 deletions

View File

@@ -14,8 +14,8 @@ import { utilFastMouse } from '../util/util';
export function behaviorSelect(context) {
// legacy option to show menu on every click
var isShowAlways = +prefs('edit-menu-show-always') === 1;
var tolerance = 4;
var _alwaysShowMenu = +prefs('edit-menu-show-always') === 1;
var _tolerancePx = 4;
var _lastMouse = null;
var _showMenu = false;
var _p1 = null;
@@ -65,7 +65,7 @@ export function behaviorSelect(context) {
d3_select(window)
.on(_pointerPrefix + 'up.select', pointerup, true);
_showMenu = isShowAlways;
_showMenu = _alwaysShowMenu;
}
@@ -110,7 +110,7 @@ export function behaviorSelect(context) {
var p2 = point();
var dist = geoVecLength(_p1, p2);
_p1 = null;
if (dist > tolerance) return;
if (dist > _tolerancePx) return;
var datum = d3_event.target.__data__ || (_lastMouse && _lastMouse.target.__data__);
var isMultiselect = d3_event.shiftKey || context.surface().select('.lasso').node();
@@ -137,25 +137,22 @@ export function behaviorSelect(context) {
context.selectedErrorID(null);
if (!isMultiselect) {
if (selectedIDs.length > 1 && (_showMenu && !isShowAlways)) {
if (selectedIDs.length > 1 && (_showMenu && !_alwaysShowMenu)) {
// multiple things already selected, just show the menu...
mode.reselect().showMenu();
} else {
if (mode.id !== 'select' || !utilArrayIdentical(mode.selectedIDs(), [datum.id])) {
newMode = modeSelect(context, [datum.id]);
// select a single thing if it's not already selected
context.enter(newMode);
if (_showMenu) newMode.showMenu();
} else {
mode.reselect();
if (_showMenu) mode.showMenu();
}
// always enter modeSelect even if the entity is already
// selected since listeners may expect `context.enter` events,
// e.g. in the walkthrough
newMode = modeSelect(context, [datum.id]);
context.enter(newMode);
if (_showMenu) newMode.showMenu();
}
} else {
if (selectedIDs.indexOf(datum.id) !== -1) {
// clicked entity is already in the selectedIDs list..
if (_showMenu && !isShowAlways) {
if (_showMenu && !_alwaysShowMenu) {
// don't deselect clicked entity, just show the menu.
mode.reselect().showMenu();
} else {

View File

@@ -343,7 +343,7 @@ export function uiIntroBuilding(context, reveal) {
var node = selectMenuItem(context, 'orthogonalize').node();
if (!node) return;
continueTo(clickSquare);
}, 300); // after menu visible
}, 50); // after menu visible
});
context.map().on('move.intro drawn.intro', function() {
@@ -386,7 +386,7 @@ export function uiIntroBuilding(context, reveal) {
}
});
context.map().on('move.intro drawn.intro', function() {
context.map().on('move.intro', function() {
var node = selectMenuItem(context, 'orthogonalize').node();
if (!wasChanged && !node) { return continueTo(rightClickHouse); }
@@ -412,7 +412,7 @@ export function uiIntroBuilding(context, reveal) {
function continueTo(nextStep) {
context.on('enter.intro', null);
context.map().on('move.intro drawn.intro', null);
context.map().on('move.intro', null);
context.history().on('change.intro', null);
nextStep();
}
@@ -661,7 +661,7 @@ export function uiIntroBuilding(context, reveal) {
var node = selectMenuItem(context, 'circularize').node();
if (!node) return;
continueTo(clickCircle);
}, 300); // after menu visible
}, 50); // after menu visible
});
revealTank(tank, t('intro.buildings.rightclick_tank'));
@@ -708,7 +708,7 @@ export function uiIntroBuilding(context, reveal) {
}
});
context.map().on('move.intro drawn.intro', function() {
context.map().on('move.intro', function() {
var node = selectMenuItem(context, 'circularize').node();
if (!wasChanged && !node) { return continueTo(rightClickTank); }
@@ -724,7 +724,7 @@ export function uiIntroBuilding(context, reveal) {
// Something changed. Wait for transition to complete and check undo annotation.
timeout(function() {
if (context.history().undoAnnotation() === t('operations.circularize.annotation.area')) {
if (context.history().undoAnnotation() === t('operations.circularize.annotation.single')) {
continueTo(play);
} else {
continueTo(retryClickCircle);
@@ -734,7 +734,7 @@ export function uiIntroBuilding(context, reveal) {
function continueTo(nextStep) {
context.on('enter.intro', null);
context.map().on('move.intro drawn.intro', null);
context.map().on('move.intro', null);
context.history().on('change.intro', null);
nextStep();
}

View File

@@ -125,7 +125,6 @@ export function uiIntro(context) {
let chapters = chapterFlow.map((chapter, i) => {
let s = chapterUi[chapter](context, curtain.reveal)
.on('done', () => {
presetManager.init(); // clear away "recent" presets
buttons
.filter(d => d.title === s.title)

View File

@@ -676,7 +676,7 @@ export function uiIntroLine(context, reveal) {
var node = selectMenuItem(context, 'split').node();
if (!node) return;
continueTo(splitIntersection);
}, 300); // after menu visible
}, 50); // after menu visible
});
context.history().on('change.intro', function() {

View File

@@ -295,6 +295,11 @@ export function uiIntroNavigation(context, reveal) {
var onClick = function() { continueTo(fieldsTownHall); };
reveal('.entity-editor-pane .section-feature-type',
t('intro.navigation.preset_townhall', { preset: preset.name() }),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
);
context.on('exit.intro', function() {
continueTo(clickTownHall);
});
@@ -305,11 +310,6 @@ export function uiIntroNavigation(context, reveal) {
}
});
reveal('.entity-editor .preset-list-item',
t('intro.navigation.preset_townhall', { preset: preset.name() }),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
);
function continueTo(nextStep) {
context.on('exit.intro', null);
context.history().on('change.intro', null);
@@ -329,7 +329,7 @@ export function uiIntroNavigation(context, reveal) {
var onClick = function() { continueTo(closeTownHall); };
reveal('.inspector-body .preset-editor',
reveal('.entity-editor-pane .section-preset-fields',
t('intro.navigation.fields_townhall'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
);

View File

@@ -388,7 +388,7 @@ export function uiIntroPoint(context, reveal) {
reveal(box, t('intro.points.rightclick'), { duration: 600 });
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
context.map().on('move.intro', function() {
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var box = pointBox(entity.loc, context);
@@ -405,12 +405,12 @@ export function uiIntroPoint(context, reveal) {
var node = selectMenuItem(context, 'delete').node();
if (!node) return;
continueTo(enterDelete);
}, 300); // after menu visible
}, 50); // after menu visible
});
function continueTo(nextStep) {
context.on('enter.intro', null);
context.map().on('move.intro drawn.intro', null);
context.map().on('move.intro', null);
nextStep();
}
}
@@ -429,7 +429,7 @@ export function uiIntroPoint(context, reveal) {
);
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
context.map().on('move.intro', function() {
revealEditMenu(entity.loc,
t('intro.points.delete', { button: icon('#iD-operation-delete', 'pre-text') }),
{ duration: 0}
@@ -450,7 +450,7 @@ export function uiIntroPoint(context, reveal) {
});
function continueTo(nextStep) {
context.map().on('move.intro drawn.intro', null);
context.map().on('move.intro', null);
context.history().on('change.intro', null);
context.on('exit.intro', null);
nextStep();