From 36536109b91b64cd52c541993fc84c2454f25b64 Mon Sep 17 00:00:00 2001 From: Efflam <efflam-fifi@hotmail.fr> Date: Sat, 2 May 2020 19:59:02 +0200 Subject: [PATCH] Fix BlackBox update when navigating to parent Schematic --- TODO.md | 2 -- Wiring/Components/BlackBox.cs | 9 ++++----- Wiring/Editor.cs | 4 ++-- Wiring/Game1.cs | 8 ++++++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index a14c15f..efc4a98 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ ### Relecture et Nettoyage du projet : * Editor -* Editor : fix panoramique * Schematic * Wire * Component @@ -29,7 +28,6 @@ * Bug : entrée-sorties (fixé ?) * Système de delay : vérifier les bugs / rendre plus propre ? * Panoramique à fix ? -* Petit bug : les fils ne sont pas toujours update dans les blackbox (mais pas de problème global détécté pour l'instant) ? * Sauvegarde des schematics : save les blackbox dans un autre fichier * Création de fil : pouvoir créer à partir du petit morceau de fil qui dépasse diff --git a/Wiring/Components/BlackBox.cs b/Wiring/Components/BlackBox.cs index 2dfef2e..44fe288 100644 --- a/Wiring/Components/BlackBox.cs +++ b/Wiring/Components/BlackBox.cs @@ -38,13 +38,12 @@ namespace Wiring public override bool GetOutput(Wire wire) { - for (int i = 0; i < outputs.Count; i++) + int i = wires.IndexOf(wire); + if (i >= inputs.Count && i < wires.Count) { - if (wire == wires[inputs.Count + i]) - { - return outputs[i].GetValue(); - } + return outputs[i - inputs.Count].GetValue(); } + return base.GetOutput(wire); } public override void Update() diff --git a/Wiring/Editor.cs b/Wiring/Editor.cs index 1e76c7a..1a16318 100644 --- a/Wiring/Editor.cs +++ b/Wiring/Editor.cs @@ -464,11 +464,11 @@ namespace Wiring } // debug - foreach (Component c in selected) + /*foreach (Component c in selected) { if (c is Output o) Console.WriteLine(gameTime.TotalGameTime.Milliseconds + " " + o.GetValue()); - } + }*/ } /// <summary> /// Transforme le position de la souris en fonction de la camra et des bordures de l'éditeur diff --git a/Wiring/Game1.cs b/Wiring/Game1.cs index 08ada8d..4be590f 100644 --- a/Wiring/Game1.cs +++ b/Wiring/Game1.cs @@ -37,7 +37,7 @@ namespace Wiring Content.RootDirectory = "Content"; Window.AllowUserResizing = true; IsMouseVisible = true; - //TargetElapsedTime = TimeSpan.FromSeconds(0.5); + //TargetElapsedTime = TimeSpan.FromSeconds(0.25); } /// <summary> @@ -421,14 +421,18 @@ namespace Wiring { savePath = ""; // reset // Supprime le dernier element de editor.schemPile et SchematicPath + string lastBlackBoxName = editor.schemPile[id + 1].Name; editor.schemPile.RemoveRange(id + 1, editor.schemPile.Count - id - 1); SchematicPath.RemoveRange(id + 1, SchematicPath.Count - id - 1); // Set tooltips SchematicPath[SchematicPath.Count - 1].ToolTip = "Renommer"; // Reload plugs, selection and wires foreach (Component c in editor.mainSchem.components) - if (c is BlackBox bb) + if (c is BlackBox bb && bb.schem.Name == lastBlackBoxName) + { bb.ReloadPlugsFromSchematic(true); + bb.Update(); + } editor.clearSelection(); editor.mainSchem.ReloadWiresFromComponents(); } -- GitLab