specify default input/output text/byte mode per level

This commit is contained in:
Crispy 2024-10-07 17:33:53 +02:00
parent e9b03b937b
commit 70d7256e9d
4 changed files with 17 additions and 5 deletions

View file

@ -5,9 +5,7 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
## todo ## todo
cleanup: unpowered texture names x_off -> x cleanup: unpowered texture names x_off -> x
(option) display input as numbers
scroll output scroll output
default i/o text modes specified per level
properly center view properly center view
make marble movement not order-dependent (`>ooo <` does not behave symmetrically) make marble movement not order-dependent (`>ooo <` does not behave symmetrically)
blueprints blueprints

View file

@ -5,5 +5,7 @@
"description": "read input and output the same thing", "description": "read input and output the same thing",
"init_board": null, "init_board": null,
"inputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33], "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
} }

View file

@ -89,8 +89,8 @@ impl Editor {
view_offset: Vector2::zero(), view_offset: Vector2::zero(),
zoom: 1, zoom: 1,
active_tool: Tool::None, active_tool: Tool::None,
output_as_text: false, output_as_text: level.output_is_text(),
input_as_text: false, input_as_text: level.input_is_text(),
input_text_selected: false, input_text_selected: false,
sim_speed: 8, sim_speed: 8,
time_since_step: 0., time_since_step: 0.,

View file

@ -11,6 +11,10 @@ pub struct Level {
init_board: Option<String>, init_board: Option<String>,
inputs: Vec<u8>, inputs: Vec<u8>,
outputs: Vec<u8>, outputs: Vec<u8>,
#[serde(default)]
input_is_text: bool,
#[serde(default)]
output_is_text: bool,
} }
impl Level { impl Level {
@ -45,4 +49,12 @@ impl Level {
pub fn outputs(&self) -> &[u8] { pub fn outputs(&self) -> &[u8] {
&self.outputs &self.outputs
} }
pub fn input_is_text(&self) -> bool {
self.input_is_text
}
pub fn output_is_text(&self) -> bool {
self.output_is_text
}
} }