mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
makes the tutorial more robust
This commit is contained in:
parent
fb0b0e4581
commit
bc3770bc54
@ -48,7 +48,7 @@ public class InitialTutorial extends JDialog implements CircuitComponent.Tutoria
|
|||||||
STEPS.add(new Step("tutorial2", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION)));
|
STEPS.add(new Step("tutorial2", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION)));
|
||||||
STEPS.add(new Step("tutorial3", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION)));
|
STEPS.add(new Step("tutorial3", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION)));
|
||||||
STEPS.add(new Step("tutorial4", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION, Out.DESCRIPTION)));
|
STEPS.add(new Step("tutorial4", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION, Out.DESCRIPTION)));
|
||||||
STEPS.add(new Step("tutorial5", (cc, mod, t) -> contains(mod, ModifyInsertWire.class)));
|
STEPS.add(new Step("tutorial5", (cc, mod, t) -> contains(mod, ModifyInsertWire.class) || isWorking(cc)));
|
||||||
STEPS.add(new Step("tutorial6", (cc, mod, t) -> isWorking(cc)));
|
STEPS.add(new Step("tutorial6", (cc, mod, t) -> isWorking(cc)));
|
||||||
STEPS.add(new Step("tutorial7", (cc, mod, t) -> t.main.getModel() != null));
|
STEPS.add(new Step("tutorial7", (cc, mod, t) -> t.main.getModel() != null));
|
||||||
STEPS.add(new Step("tutorial8", (cc, mod, t) -> outputIsHigh(t)));
|
STEPS.add(new Step("tutorial8", (cc, mod, t) -> outputIsHigh(t)));
|
||||||
@ -99,10 +99,12 @@ public class InitialTutorial extends JDialog implements CircuitComponent.Tutoria
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num == expected;
|
return num >= expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWorking(CircuitComponent cc) {
|
private static boolean isWorking(CircuitComponent cc) {
|
||||||
|
if (cc.getCircuit().getElements().size() < 4)
|
||||||
|
return false;
|
||||||
try {
|
try {
|
||||||
new ModelCreator(cc.getCircuit(), cc.getLibrary()).createModel(false);
|
new ModelCreator(cc.getCircuit(), cc.getLibrary()).createModel(false);
|
||||||
return true;
|
return true;
|
||||||
@ -127,7 +129,7 @@ public class InitialTutorial extends JDialog implements CircuitComponent.Tutoria
|
|||||||
|
|
||||||
private static boolean contains(CircuitComponent cc, ElementTypeDescription... descriptions) {
|
private static boolean contains(CircuitComponent cc, ElementTypeDescription... descriptions) {
|
||||||
ArrayList<VisualElement> el = new ArrayList<>(cc.getCircuit().getElements());
|
ArrayList<VisualElement> el = new ArrayList<>(cc.getCircuit().getElements());
|
||||||
if (el.size() != descriptions.length)
|
if (el.size() < descriptions.length)
|
||||||
return false;
|
return false;
|
||||||
for (ElementTypeDescription d : descriptions) {
|
for (ElementTypeDescription d : descriptions) {
|
||||||
Iterator<VisualElement> it = el.iterator();
|
Iterator<VisualElement> it = el.iterator();
|
||||||
@ -195,7 +197,10 @@ public class InitialTutorial extends JDialog implements CircuitComponent.Tutoria
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void incIndex() {
|
private void incIndex() {
|
||||||
stepIndex++;
|
do {
|
||||||
|
stepIndex++;
|
||||||
|
} while (stepIndex < STEPS.size()
|
||||||
|
&& STEPS.get(stepIndex).getChecker().accomplished(circuitComponent, null, this));
|
||||||
if (stepIndex == STEPS.size()) {
|
if (stepIndex == STEPS.size()) {
|
||||||
disableTutorial();
|
disableTutorial();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user