mirror of
https://github.com/Stone-Red-Code/StoneRed.LogicSimulator.git
synced 2026-09-04 00:56:23 +02:00
Simple display test
This commit is contained in:
@@ -11,19 +11,43 @@ namespace StoneRed.LogicSimulator.Simulation.LogicGates;
|
||||
[LogicGateName("Test")]
|
||||
internal class TestLogicGate : LogicGate, Interfaces.IDrawable
|
||||
{
|
||||
public override int OutputCount { get; set; } = 1;
|
||||
public override int InputCount { get; set; } = 1;
|
||||
private readonly Color[] colors = new Color[9];
|
||||
private Texture2D texture = null!;
|
||||
public override int OutputCount { get; set; } = 0;
|
||||
public override int InputCount { get; set; } = 9;
|
||||
|
||||
public Texture2D Texture => CreateTexture(1, 1);
|
||||
public Texture2D Texture
|
||||
{
|
||||
get
|
||||
{
|
||||
Draw();
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void Initialize()
|
||||
{
|
||||
texture = CreateTexture(3, 3);
|
||||
texture.SetData(new Color[]
|
||||
{
|
||||
Color.Red, Color.Blue, Color.Red,
|
||||
Color.Blue, Color.Red, Color.Blue,
|
||||
Color.Red, Color.Blue, Color.Red
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Execute()
|
||||
{
|
||||
Texture.SetData(new Color[] { Color.Red });
|
||||
|
||||
for (int i = 0; i < InputCount; i++)
|
||||
{
|
||||
SetOutputBit(GetInputBit(i), i);
|
||||
colors[i] = GetInputBit(i) == 1 ? Color.Red : Color.Gray;
|
||||
}
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
texture.SetData(colors);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -98,7 +98,7 @@ internal class WorldScreen : SrlsScreen<Grid>
|
||||
fps = 1f / gameTime.GetElapsedSeconds();
|
||||
|
||||
Matrix transformMatrix = camera.GetViewMatrix();
|
||||
srls.SpriteBatch.Begin(SpriteSortMode.BackToFront, transformMatrix: transformMatrix);
|
||||
srls.SpriteBatch.Begin(SpriteSortMode.BackToFront, samplerState: SamplerState.PointClamp, transformMatrix: transformMatrix);
|
||||
|
||||
foreach (LogicGate logicGate in simulator.GetLogicGates())
|
||||
{
|
||||
@@ -336,11 +336,11 @@ internal class WorldScreen : SrlsScreen<Grid>
|
||||
|
||||
if (connectionContext.IsInput)
|
||||
{
|
||||
isConnected = logicGate.IsConnectedTo(connectionContext.LogicGate);
|
||||
isConnected = logicGate.IsConnectedTo(connectionContext.LogicGate, connectionContext.Index, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
isConnected = connectionContext.LogicGate.IsConnectedTo(logicGate);
|
||||
isConnected = connectionContext.LogicGate.IsConnectedTo(logicGate, i, connectionContext.Index);
|
||||
}
|
||||
|
||||
connectionStatus = isConnected ? "[Disconnect]" : "[Connect]";
|
||||
@@ -382,9 +382,9 @@ internal class WorldScreen : SrlsScreen<Grid>
|
||||
|
||||
if (connectionContext.IsInput)
|
||||
{
|
||||
if (logicGate.IsConnectedTo(connectionContext.LogicGate))
|
||||
if (logicGate.IsConnectedTo(connectionContext.LogicGate, connectionContext.Index, index))
|
||||
{
|
||||
logicGate.Disconnect(connectionContext.LogicGate);
|
||||
logicGate.Disconnect(connectionContext.LogicGate, connectionContext.Index, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,9 +393,9 @@ internal class WorldScreen : SrlsScreen<Grid>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectionContext.LogicGate.IsConnectedTo(logicGate))
|
||||
if (connectionContext.LogicGate.IsConnectedTo(logicGate, index, connectionContext.Index))
|
||||
{
|
||||
connectionContext.LogicGate.Disconnect(logicGate);
|
||||
connectionContext.LogicGate.Disconnect(logicGate, index, connectionContext.Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user