Skip to content

Commit

Permalink
Polish rust tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger committed Feb 2, 2022
1 parent 7bf6c48 commit a0d89c0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/tutorial/rust/src/creating_the_tiles_from_rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The tiles in the game should have a random placement. We'll need to add the <`ra

```toml
[dependencies]
sixtyfps = "0.1.6"
slint = "0.2.0"
rand = "0.8" # Added
```

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/rust/src/from_one_to_multiple_tiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ to create many instances of the same element. In `.slint` the for loop is declar
the model changes. We instantiate all the different <span class="hljs-title">MemoryTile</span> elements and place them on a grid based on their
index with a little bit of spacing between the tiles.

First, we copy the tile data structure definition and paste it at top inside the `sixtyfps!` macro:
First, we copy the tile data structure definition and paste it at top inside the `slint!` macro:

```slint
{{#include main_multiple_tiles.rs:tile_data}}
```

Next, we replace the *<span class="hljs-title">MainWindow</span> := { ... }* section at the bottom of the `sixtyfps!` macro with the following snippet:
Next, we replace the *<span class="hljs-title">MainWindow</span> := { ... }* section at the bottom of the `slint!` macro with the following snippet:

```slint
{{#include main_multiple_tiles.rs:main_window}}
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/rust/src/game_logic_in_rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ language. The game rules shall enforce that at most two tiles have their curtain
consider them solved and they remain open. Otherwise we wait for a little while, so the player can memorize
the location of the icons, and then close them again.

We'll modify the `.slint` markup inside the `sixtyfps!` macro to signal to the Rust code when the user clicks on a tile.
We'll modify the `.slint` markup inside the `slint!` macro to signal to the Rust code when the user clicks on a tile.
Two changes to <span class="hljs-title">MainWindow</span> are needed: We need to add a way for the MainWindow to call to the Rust code that it should
check if a pair of tiles has been solved. And we need to add a property that Rust code can toggle to disable further
tile interaction, to prevent the player from opening more tiles than allowed. No cheating allowed! First, we paste
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/rust/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ cargo new memory
cd memory
```

Then we edit `Cargo.toml` to add the sixtyfps dependency:
Then we edit `Cargo.toml` to add the slint dependency:

```toml
[package]
#...
edition = "2021"

[dependencies]
sixtyfps = "0.1.6"
slint = "0.2.0"
```

Finally we copy the hello world program from the [Slint documentation](https://sixtyfps.io/docs/rust/sixtyfps/) into our `src/main.rs`:
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/rust/src/memory_tile.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ and it is filled with a soothing tone of blue. Note how lengths in the `.slint`
the `px` suffix. That makes the code easier to read and the compiler can detect when your are accidentally
mixing values with different units attached to them.

We copy the following code inside of the `sixtyfps!` macro:
We copy the following code inside of the `slint!` macro:

```slint
{{#include main_memory_tile.rs:tile}}
```

Inside the <span class="hljs-built_in">Rectangle</span> we place an <span class="hljs-built_in">Image</span> element that
loads an icon with the <span class="hljs-built_in">@image-url()</span> macro.
When using the `sixtyfps!` macro, the path is relative to the folder in which the Cargo.toml is located.
When using the `slint!` macro, the path is relative to the folder in which the Cargo.toml is located.
When using .slint files, it is relative to the folder of the .slint file containing it.
This icon and others we're going to use later need to be installed first. You can download a
[Zip archive](https://sixtyfps.io/blog/memory-game-tutorial/icons.zip) that we have prepared and extract it with the
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/rust/src/polishing_the_tile.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ more in detail:
In order to make our tile extensible, the hard-coded icon name is replaced with an *icon*
property that can be set from the outside when instantiating the element. For the final polish, we add a
*solved* property that we use to animate the color to a shade of green when we've found a pair, later. We
replace the code inside the `sixtyfps!` macro with the following:
replace the code inside the `slint!` macro with the following:

```slint
{{#include main_polishing_the_tile.rs:tile}}
Expand Down

0 comments on commit a0d89c0

Please sign in to comment.