fixed player_0_1s bug

This commit is contained in:
Matei Adriel 2019-07-28 12:31:30 +03:00
parent c4883b9484
commit efa3086389
4 changed files with 24 additions and 4 deletions

View file

@ -4,7 +4,6 @@ import React from 'react'
const title = 'Logic gate simulator'
const description = 'A logic gate simulator made for infoeducatie 2019'
const url = 'https://logic-gate-simulator.herokuapp.com/'
const thumbail = require('../../../assets/thumbail.png')
const Head = () => {
return (
@ -31,7 +30,6 @@ const Head = () => {
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={`${url}${thumbail}`} />
<meta property="og:url" content={url} />
<link rel="icon" href={require('../../../assets/favicon.ico')} />

View file

@ -3,6 +3,6 @@ import { deleteGate } from '../../simulationRenderer/helpers/deleteGate'
export const deleteSelection = (renderer: SimulationRenderer) => {
for (const gate of renderer.getSelected()) {
deleteGate(renderer.simulation, gate)
deleteGate(renderer.simulation, gate, renderer)
}
}

View file

@ -364,4 +364,12 @@ export class SimulationRenderer {
this.selectedGates.permanent.clear()
this.selectedGates.temporary.clear()
}
/**
* Clears the selected pins of the renderer
*/
public clearPinSelection() {
this.selectedPins.end = null
this.selectedPins.start = null
}
}

View file

@ -9,7 +9,11 @@ import { Simulation } from '../../simulation/classes/Simulation'
* @param simulation The simulation to remove the gate from
* @param gate The gate to remove
*/
export const deleteGate = (simulation: Simulation, gate: Gate) => {
export const deleteGate = (
simulation: Simulation,
gate: Gate,
renderer?: SimulationRenderer
) => {
const node = simulation.gates.get(gate.id)
if (!node) {
@ -26,4 +30,14 @@ export const deleteGate = (simulation: Simulation, gate: Gate) => {
gate.dispose()
simulation.gates.delete(node)
if (
renderer &&
((renderer.selectedPins.end &&
renderer.selectedPins.end.wrapper.value.gate === gate) ||
(renderer.selectedPins.start &&
renderer.selectedPins.start.wrapper.value.gate === gate))
) {
renderer.clearPinSelection()
}
}