From 70d7256e9d745d529bb67bd40cfd872add0cda38 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Mon, 7 Oct 2024 17:33:53 +0200 Subject: [PATCH] specify default input/output text/byte mode per level --- README.md | 2 -- levels/01_cat.json | 4 +++- src/editor.rs | 4 ++-- src/level.rs | 12 ++++++++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73522cc..a815a3a 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble ## todo cleanup: unpowered texture names x_off -> x -(option) display input as numbers scroll output -default i/o text modes specified per level properly center view make marble movement not order-dependent (`>ooo <` does not behave symmetrically) blueprints diff --git a/levels/01_cat.json b/levels/01_cat.json index 0318e87..39a6b5e 100644 --- a/levels/01_cat.json +++ b/levels/01_cat.json @@ -5,5 +5,7 @@ "description": "read input and output the same thing", "init_board": null, "inputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33], - "outputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33] + "outputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33], + "input_is_text": true, + "output_is_text": true } \ No newline at end of file diff --git a/src/editor.rs b/src/editor.rs index e59390a..2464af1 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -89,8 +89,8 @@ impl Editor { view_offset: Vector2::zero(), zoom: 1, active_tool: Tool::None, - output_as_text: false, - input_as_text: false, + output_as_text: level.output_is_text(), + input_as_text: level.input_is_text(), input_text_selected: false, sim_speed: 8, time_since_step: 0., diff --git a/src/level.rs b/src/level.rs index 44f4384..6ef2582 100644 --- a/src/level.rs +++ b/src/level.rs @@ -11,6 +11,10 @@ pub struct Level { init_board: Option, inputs: Vec, outputs: Vec, + #[serde(default)] + input_is_text: bool, + #[serde(default)] + output_is_text: bool, } impl Level { @@ -45,4 +49,12 @@ impl Level { pub fn outputs(&self) -> &[u8] { &self.outputs } + + pub fn input_is_text(&self) -> bool { + self.input_is_text + } + + pub fn output_is_text(&self) -> bool { + self.output_is_text + } }