|
|
|
@ -47,14 +47,24 @@ pub struct ModVersion {
|
|
|
|
|
pub struct Input {
|
|
|
|
|
circuit_state_id: Int,
|
|
|
|
|
}
|
|
|
|
|
impl Input {
|
|
|
|
|
pub fn new(circuit_state_id: Int) -> Self {
|
|
|
|
|
Self { circuit_state_id }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[derive(BinarySerializable)]
|
|
|
|
|
pub struct Output {
|
|
|
|
|
circuit_state_id: Int,
|
|
|
|
|
}
|
|
|
|
|
impl Output {
|
|
|
|
|
pub fn new(circuit_state_id: Int) -> Self {
|
|
|
|
|
Self { circuit_state_id }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(BinarySerializable)]
|
|
|
|
|
pub struct ComponentIdMap {
|
|
|
|
|
pub numeric_id: i16,
|
|
|
|
|
pub numeric_id: u16,
|
|
|
|
|
pub text_id: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -64,6 +74,22 @@ pub struct PegAddress {
|
|
|
|
|
component_address: ComponentAddress,
|
|
|
|
|
index: Int,
|
|
|
|
|
}
|
|
|
|
|
impl PegAddress {
|
|
|
|
|
pub fn input(component_address: ComponentAddress, index: Int) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
peg_type: PegType::Input,
|
|
|
|
|
component_address,
|
|
|
|
|
index,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pub fn output(component_address: ComponentAddress, index: Int) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
peg_type: PegType::Output,
|
|
|
|
|
component_address,
|
|
|
|
|
index,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(BinarySerializable)]
|
|
|
|
|
pub struct Component {
|
|
|
|
@ -79,10 +105,10 @@ pub struct Component {
|
|
|
|
|
|
|
|
|
|
#[derive(BinarySerializable)]
|
|
|
|
|
pub struct Wire {
|
|
|
|
|
first_point: PegAddress,
|
|
|
|
|
second_point: PegAddress,
|
|
|
|
|
circuit_state_id: Int,
|
|
|
|
|
wire_rotation: Float,
|
|
|
|
|
pub first_point: PegAddress,
|
|
|
|
|
pub second_point: PegAddress,
|
|
|
|
|
pub circuit_state_id: Int,
|
|
|
|
|
pub wire_rotation: Float,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct CircuitBoard {
|
|
|
|
@ -119,6 +145,85 @@ impl CircuitBoard {
|
|
|
|
|
return custom_data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pub struct Label<'a> {
|
|
|
|
|
text: &'a str,
|
|
|
|
|
color: Vec<u8>,
|
|
|
|
|
size: Float,
|
|
|
|
|
mono: bool,
|
|
|
|
|
width: Int,
|
|
|
|
|
height: Int,
|
|
|
|
|
horizontal_align: HorizontalAlign,
|
|
|
|
|
vertical_align: VerticalAlign,
|
|
|
|
|
}
|
|
|
|
|
#[repr(i32)]
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub enum HorizontalAlign {
|
|
|
|
|
Left = 0,
|
|
|
|
|
Middle = 1,
|
|
|
|
|
Right = 2,
|
|
|
|
|
}
|
|
|
|
|
#[repr(i32)]
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub enum VerticalAlign {
|
|
|
|
|
Top = 0,
|
|
|
|
|
Middle = 1,
|
|
|
|
|
Bottom = 2,
|
|
|
|
|
}
|
|
|
|
|
impl<'a> Label<'a> {
|
|
|
|
|
pub fn new(text: &'a str) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
text,
|
|
|
|
|
color: vec![51, 51, 51],
|
|
|
|
|
size: 0.8,
|
|
|
|
|
mono: false,
|
|
|
|
|
width: 1,
|
|
|
|
|
height: 1,
|
|
|
|
|
horizontal_align: HorizontalAlign::Middle,
|
|
|
|
|
vertical_align: VerticalAlign::Middle,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pub fn mono(&mut self) -> &mut Self {
|
|
|
|
|
self.mono = true;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
pub fn with_color(&mut self, r: u8, g: u8, b: u8) -> &mut Self {
|
|
|
|
|
self.color[0] = r;
|
|
|
|
|
self.color[1] = g;
|
|
|
|
|
self.color[2] = b;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
pub fn with_size(&mut self, size: Float) -> &mut Self {
|
|
|
|
|
self.size = size;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
pub fn with_dimensions(&mut self, width: Int, height: Int) -> &mut Self {
|
|
|
|
|
self.width = width;
|
|
|
|
|
self.height = height;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
pub fn with_align(
|
|
|
|
|
&mut self,
|
|
|
|
|
horizontal: HorizontalAlign,
|
|
|
|
|
vertical: VerticalAlign,
|
|
|
|
|
) -> &mut Self {
|
|
|
|
|
self.horizontal_align = horizontal;
|
|
|
|
|
self.vertical_align = vertical;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
pub fn custom_data(&self) -> Vec<u8> {
|
|
|
|
|
let mut custom_data = Vec::with_capacity(33);
|
|
|
|
|
custom_data.extend(&(self.horizontal_align as Int).to_le_bytes());
|
|
|
|
|
custom_data.extend(&self.color);
|
|
|
|
|
custom_data.extend(&self.size.to_le_bytes());
|
|
|
|
|
custom_data.extend(&[self.mono as u8]);
|
|
|
|
|
custom_data.extend(&(self.text.len() as Int).to_le_bytes());
|
|
|
|
|
custom_data.extend(self.text.as_bytes());
|
|
|
|
|
custom_data.extend(&self.width.to_le_bytes());
|
|
|
|
|
custom_data.extend(&self.height.to_le_bytes());
|
|
|
|
|
custom_data.extend(&(self.vertical_align as Int).to_le_bytes());
|
|
|
|
|
return custom_data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T: BinarySerializable> BinarySerializable for Vec<T> {
|
|
|
|
|
fn write_to<W: Write>(&self, writer: &mut W) -> io::Result<()> {
|
|
|
|
|