Skip to content

Commit

Permalink
Support initial tutorial code
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 5, 2023
1 parent a0133a3 commit b9cb58b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/state/editor_screen/code_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn spawn_code_panel(commands: &mut Commands, config: &EditorScreenConfig) ->
.spawn((
Name::new("CodePanelText"),
TextBundle::from_section(
"// Start typing to generate lines of code!\n\n",
"// Start typing to generate lines of code!\n",
TextStyle {
font: FONT_HANDLE,
color: config.code_panel_text_color,
Expand All @@ -35,7 +35,7 @@ pub fn spawn_code_panel(commands: &mut Commands, config: &EditorScreenConfig) ->
),
FontSize::new(config.code_panel_font_size),
CodeTyper {
lines_count: 3,
lines_count: 2,
lines_max: config.code_panel_lines_max,
..default()
},
Expand Down
6 changes: 4 additions & 2 deletions src/ui/code_typer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::iter::Chain;
use std::iter::Cycle;
use std::str::Chars;

Expand All @@ -14,14 +15,15 @@ impl Plugin for CodeTyperPlugin {
}
}

const TUTORIAL_CODE: &str = "// You can spend lines to add_plugins from the upgrade panel\n\n";
const FILLER_CODE: &str = include_str!("code_typer.rs");

// Newtype so that CodeTyper can derive Reflect
pub struct CodeGenerator(Cycle<Chars<'static>>);
pub struct CodeGenerator(Chain<Chars<'static>, Cycle<Chars<'static>>>);

impl Default for CodeGenerator {
fn default() -> Self {
Self(FILLER_CODE.chars().cycle())
Self(TUTORIAL_CODE.chars().chain(FILLER_CODE.chars().cycle()))
}
}

Expand Down

0 comments on commit b9cb58b

Please sign in to comment.