Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assets/Scripts/Description/Helpers/ChipTypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static class ChipTypeHelper
{ ChipType.DisplayDot, "DOT DISPLAY" },
{ ChipType.SevenSegmentDisplay, "7-SEGMENT" },
{ ChipType.DisplayLED, "LED" },
{ ChipType.FourteenSegmentDisplay, "14-Segment Display" },

// ---- Not really chips (but convenient to treat them as such anyway) ----

Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum ChipType
DisplayRGB,
DisplayDot,
DisplayLED,
FourteenSegmentDisplay,

// ---- Merge / Split ----
Merge_1To4Bit,
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/Game/Interaction/UndoController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 40 additions & 1 deletion Assets/Scripts/Game/Project/BuiltinChipCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static ChipDescription[] CreateAllBuiltinChipDescriptions()
CreateDisplayRGB(),
CreateDisplayDot(),
CreateDisplayLED(),
CreateFourteenSegmentDisplay(),
// ---- Bus ----
CreateBus(PinBitCount.Bit1),
CreateBusTerminus(PinBitCount.Bit1),
Expand Down Expand Up @@ -202,7 +203,45 @@ static ChipDescription CreateDisplay7Seg()
return CreateBuiltinChipDescription(ChipType.SevenSegmentDisplay, size, col, inputPins, null, displays, true);
}

static ChipDescription CreateDisplayRGB()
static ChipDescription CreateFourteenSegmentDisplay()
{
PinDescription[] inputPins =
{
CreatePinDescription("A", 0),
CreatePinDescription("B", 1),
CreatePinDescription("C", 2),
CreatePinDescription("D", 3),
CreatePinDescription("E", 4),
CreatePinDescription("F", 5),
CreatePinDescription("G", 6),
CreatePinDescription("H", 7),
CreatePinDescription("I", 8),
CreatePinDescription("J", 9),
CreatePinDescription("K", 10),
CreatePinDescription("L", 11),
CreatePinDescription("M", 12),
CreatePinDescription("N", 13),
CreatePinDescription("COL", 14)
};

Color col = new(0.1f, 0.1f, 0.1f);
float height = SubChipInstance.MinChipHeightForPins(inputPins, null);
Vector2 size = new(GridSize * 13, height);
float displayWidth = (float)((size.x * 1.5) - (GridSize * 2));

DisplayDescription[] displays =
{
new()
{
Position = Vector2.right * PinRadius / 3 * 0,
Scale = displayWidth,
SubChipID = -1
}
};
return CreateBuiltinChipDescription(ChipType.FourteenSegmentDisplay, size, col, inputPins, null, displays, true);
}

static ChipDescription CreateDisplayRGB()
{
float height = GridSize * 21;
float width = height;
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/Graphics/UI/Menus/PulseEditMenu.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 80 additions & 2 deletions Assets/Scripts/Graphics/World/DevSceneDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,30 @@ public static Bounds2D DrawDisplay(DisplayInstance display, Vector2 posParent, f
int G = (simActive && sim.InputPins[6].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[6] ? DisplayHighlightState : DisplayOffState) + colOffset;
bounds = DrawDisplay_SevenSegment(posWorld, scaleWorld, A, B, C, D, E, F, G);
}
else if (display.DisplayType == ChipType.DisplayRGB)
else if (display.DisplayType is ChipType.FourteenSegmentDisplay)
{
bool simActive = sim != null;
bool hoverActive = rootChip.ChipType == ChipType.SevenSegmentDisplay;
PinInstance pin = InteractionState.PinUnderMouse;
int colOffset = simActive && sim.InputPins[14].FirstBitHigh ? 3 : 0;

int A = (simActive && sim.InputPins[0].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[0] ? DisplayHighlightState : DisplayOffState) + colOffset;
int B = (simActive && sim.InputPins[1].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[1] ? DisplayHighlightState : DisplayOffState) + colOffset;
int C = (simActive && sim.InputPins[2].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[2] ? DisplayHighlightState : DisplayOffState) + colOffset;
int D = (simActive && sim.InputPins[3].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[3] ? DisplayHighlightState : DisplayOffState) + colOffset;
int E = (simActive && sim.InputPins[4].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[4] ? DisplayHighlightState : DisplayOffState) + colOffset;
int F = (simActive && sim.InputPins[5].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[5] ? DisplayHighlightState : DisplayOffState) + colOffset;
int G = (simActive && sim.InputPins[6].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[6] ? DisplayHighlightState : DisplayOffState) + colOffset;
int H = (simActive && sim.InputPins[7].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[7] ? DisplayHighlightState : DisplayOffState) + colOffset;
int I = (simActive && sim.InputPins[8].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[8] ? DisplayHighlightState : DisplayOffState) + colOffset;
int J = (simActive && sim.InputPins[9].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[9] ? DisplayHighlightState : DisplayOffState) + colOffset;
int K = (simActive && sim.InputPins[10].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[10] ? DisplayHighlightState : DisplayOffState) + colOffset;
int L = (simActive && sim.InputPins[11].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[11] ? DisplayHighlightState : DisplayOffState) + colOffset;
int M = (simActive && sim.InputPins[12].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[12] ? DisplayHighlightState : DisplayOffState) + colOffset;
int N = (simActive && sim.InputPins[13].FirstBitHigh ? DisplayOnState : hoverActive && pin == rootChip.AllPins[13] ? DisplayHighlightState : DisplayOffState) + colOffset;
bounds = DrawDisplay_FourteenSegment(posWorld, scaleWorld, A, B, C, D, E, F, G, H, I, J, K, L, M, N);
}
else if (display.DisplayType == ChipType.DisplayRGB)
{
bounds = DrawDisplay_RGB(posWorld, scaleWorld, sim);
}
Expand Down Expand Up @@ -567,7 +590,62 @@ public static Bounds2D DrawDisplay_SevenSegment(Vector2 centre, float scale, int
return Bounds2D.CreateFromCentreAndSize(centre, boundsSize);
}

public static Bounds2D DrawDisplay_DisplayLED(Vector2 centre, float scale, bool isOn)
public static Bounds2D DrawDisplay_FourteenSegment(Vector2 centre, float scale, int A, int B, int C, int D, int E, int F, int G, int H, int I, int J, int K, int L, int M, int N)
{
const float targetHeightAspect = 1.75f;
const float segmentThicknessFac = 0.165f;
const float segmentVerticalSpacingFac = 0.07f;
const float displayInsetFac = 0.2f;

float boundsWidth = scale;
float boundsHeight = boundsWidth * targetHeightAspect;
float segmentThickness = scale * segmentThicknessFac;

// Width of horizontal segments
float segmentWidth = boundsWidth - segmentThickness - scale * displayInsetFac;
// Distance between the centres of the bottom-most and top-most segments
float segmentRegionHeight = boundsHeight - segmentThickness - scale * displayInsetFac;
// Height of the vertical segments
float segmentHeight = segmentRegionHeight / 2 - scale * segmentVerticalSpacingFac;

Vector2 segmentSizeVertical = new(segmentThickness / 2, segmentHeight);
Vector2 segmentSizeHorizontal = new(segmentWidth, segmentThickness / 2);
Vector2 segmentSizeDiagonal = new(segmentThickness / 2, (float)Math.Sqrt(((segmentSizeHorizontal.x) * (segmentSizeHorizontal.x)) + ((segmentSizeVertical.y) * (segmentSizeVertical.y))));
Vector2 offsetX = Vector2.right * segmentWidth / 2;
Vector2 offsetY = Vector2.up * segmentRegionHeight / 4;

Color[] cols = ActiveTheme.SevenSegCols;

// Draw bounds
Vector2 boundsSize = new(boundsWidth, boundsHeight);
Draw.Quad(centre, boundsSize, Color.black);

// Draw horizontal segments
Draw.Diamond(centre - (offsetX / 2), new Vector2(segmentWidth / 2, segmentThickness / 2), cols[G]); // mid left
Draw.Diamond(centre + (offsetX / 2), new Vector2(segmentWidth / 2, segmentThickness / 2), cols[H]); // mid right

Draw.Diamond(centre + Vector2.up * segmentRegionHeight / 2, segmentSizeHorizontal, cols[A]); // top
Draw.Diamond(centre - Vector2.up * segmentRegionHeight / 2, segmentSizeHorizontal, cols[D]); // bottom

// Draw vertical segments
Draw.Diamond(centre - offsetX + offsetY, segmentSizeVertical, cols[F]); // left top
Draw.Diamond(centre - offsetX - offsetY, segmentSizeVertical, cols[E]); // left bottom
Draw.Diamond(centre + offsetX + offsetY, segmentSizeVertical, cols[B]); // right top
Draw.Diamond(centre + offsetX - offsetY, segmentSizeVertical, cols[C]); // right bottom

Draw.Diamond(centre + offsetY, segmentSizeVertical, cols[I]); // mid top
Draw.Diamond(centre - offsetY, segmentSizeVertical, cols[J]); // mid bottom

//Draw Diagonal Segments
Draw.Line(centre + new Vector2(-.5f, 1.3f), centre + new Vector2(-.1f, .13f), segmentThickness / 5, cols[K]);
Draw.Line(centre + new Vector2(.5f, 1.3f), centre + new Vector2(.1f, .13f), segmentThickness / 5, cols[L]);
Draw.Line(centre + new Vector2(.5f, -1.3f), centre + new Vector2(.1f, -.13f), segmentThickness / 5, cols[M]);
Draw.Line(centre + new Vector2(-.5f, -1.3f), centre + new Vector2(-.1f, -.13f), segmentThickness / 5, cols[N]);

return Bounds2D.CreateFromCentreAndSize(centre, boundsSize);
}

public static Bounds2D DrawDisplay_DisplayLED(Vector2 centre, float scale, bool isOn)
{
const float pixelSizeT = 0.975f;
float pixelSize = scale;
Expand Down
16 changes: 9 additions & 7 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"dependencies": {
"com.unity.ext.nunit": {
"version": "2.0.5",
"version": "1.0.6",
"depth": 1,
"source": "builtin",
"dependencies": {}
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.36",
Expand Down Expand Up @@ -41,14 +42,15 @@
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.5.1",
"version": "1.1.33",
"depth": 1,
"source": "builtin",
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "2.0.3",
"com.unity.ext.nunit": "1.0.6",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
},
"url": "https://packages.unity.com"
},
"com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.10",
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 6000.0.46f1
m_EditorVersionWithRevision: 6000.0.46f1 (fb93bc360d3a)
m_EditorVersion: 2022.3.11f1
m_EditorVersionWithRevision: 2022.3.11f1 (d00248457e15)
Loading