load program input when opening a solution
This commit is contained in:
parent
146618cdc3
commit
4a51369b18
4 changed files with 7 additions and 21 deletions
|
@ -72,7 +72,7 @@ impl Editor {
|
|||
pub fn new(solution: Solution, level: Level) -> Self {
|
||||
Self {
|
||||
source_board: Board::parse(&solution.board),
|
||||
machine: Machine::new_empty(1),
|
||||
machine: Machine::new_empty(level.inputs().to_owned(), 1),
|
||||
sim_state: SimState::Editing,
|
||||
view_offset: Vector2::zero(),
|
||||
zoom: 1,
|
||||
|
@ -369,7 +369,7 @@ impl Editor {
|
|||
let output_start = self.machine.output().len().saturating_sub(8);
|
||||
let output_end = output_start + 8;
|
||||
for (box_index, index) in (output_start..output_end).enumerate() {
|
||||
let x = 600 + 35 * box_index as i32;
|
||||
let x = 600 + 43 * box_index as i32;
|
||||
|
||||
let expected_byte = self.level.outputs().get(index);
|
||||
let real_byte = self.machine.output().get(index);
|
||||
|
@ -385,8 +385,8 @@ impl Editor {
|
|||
(Color::DARKGRAY, Color::DIMGRAY)
|
||||
};
|
||||
|
||||
d.draw_rectangle(x, y, 30, 30, top_color);
|
||||
d.draw_rectangle(x, y + 35, 30, 30, bottom_color);
|
||||
d.draw_rectangle(x, y, 38, 30, top_color);
|
||||
d.draw_rectangle(x, y + 35, 38, 30, bottom_color);
|
||||
if let Some(&expected_byte) = expected_byte {
|
||||
let top_text = if self.output_as_text
|
||||
&& (expected_byte.is_ascii_graphic() || expected_byte.is_ascii_whitespace())
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::marble_engine::board::Board;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Level {
|
||||
id: String,
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -89,22 +89,10 @@ impl Game {
|
|||
|
||||
fn draw(&mut self, d: &mut RaylibDrawHandle) {
|
||||
d.clear_background(Color::new(64, 64, 64, 255));
|
||||
// let level_list_width = 240;
|
||||
|
||||
let level_list_width = d.get_screen_width() / 4; // woah! Reactive UI! so fancy
|
||||
let screen_height = d.get_screen_height();
|
||||
d.draw_rectangle(0, 0, level_list_width, screen_height, Color::GRAY);
|
||||
// let (a, b, c) = d.gui_scroll_panel(
|
||||
// Rectangle {
|
||||
// x: 10.,
|
||||
// y: 10.,
|
||||
// width: level_list_width as f32 - 20.,
|
||||
// height: screen_height as f32 - 40.,
|
||||
// },
|
||||
// Some(rstr!("text")),
|
||||
// Rectangle{},
|
||||
// scroll,
|
||||
// view,
|
||||
// );
|
||||
|
||||
let clicked = d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT);
|
||||
let mouse_pos = d.get_mouse_position();
|
||||
|
|
|
@ -17,11 +17,11 @@ pub struct Machine {
|
|||
}
|
||||
|
||||
impl Machine {
|
||||
pub fn new_empty(width: usize) -> Self {
|
||||
pub fn new_empty(input:Vec<u8>,width: usize) -> Self {
|
||||
Self {
|
||||
board: Board::new_empty(width, width),
|
||||
marbles: Vec::new(),
|
||||
input: Vec::new(),
|
||||
input,
|
||||
input_index: 0,
|
||||
output: Vec::new(),
|
||||
steps: 0,
|
||||
|
|
Loading…
Reference in a new issue