Fix links from the tutorial to the Rust crates

The crate has been renamed. There's a redirect in place, so the release docs should be ok,
but in the future we should use the right name.
This commit is contained in:
Simon Hausmann 2022-02-10 13:25:46 +01:00
parent eb320b0a99
commit a9c76d44a2
5 changed files with 10 additions and 10 deletions

View file

@ -2,12 +2,12 @@
The game is visually a little bare. Here are some ideas how you could make further changes to enhance it: The game is visually a little bare. Here are some ideas how you could make further changes to enhance it:
* The tiles could have rounded corners, to look a little less sharp. The [border-radius](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#rectangle) * The tiles could have rounded corners, to look a little less sharp. The [border-radius](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#rectangle)
property of *Rectangle* can be used to achieve that. property of *Rectangle* can be used to achieve that.
* In real world memory games, the back of the tiles often have some common graphic. You could add an image with * In real world memory games, the back of the tiles often have some common graphic. You could add an image with
the help of another *[Image](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#image)* the help of another *[Image](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#image)*
element. Note that you may have to use *Rectangle*'s *[clip](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#properties-1) property* element. Note that you may have to use *Rectangle*'s *[clip](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#properties-1) property*
element around it to ensure that the image is clipped away when the curtain effect opens. element around it to ensure that the image is clipped away when the curtain effect opens.
Let us know in the comments on Github Discussions how you polished your code, or feel free to ask questions about Let us know in the comments on Github Discussions how you polished your code, or feel free to ask questions about

View file

@ -12,9 +12,9 @@ rand = "0.8" # Added
What we'll do is take the list of tiles declared in the .slint language, duplicate it, and shuffle it. What we'll do is take the list of tiles declared in the .slint language, duplicate it, and shuffle it.
We'll do so by accessing the `memory_tiles` property through the Rust code. For each top-level property, We'll do so by accessing the `memory_tiles` property through the Rust code. For each top-level property,
a getter and a setter function is generated - in our case `get_memory_tiles` and `set_memory_tiles`. a getter and a setter function is generated - in our case `get_memory_tiles` and `set_memory_tiles`.
Since `memory_tiles` is an array in the `.slint` language, it is represented as a [`Rc<dyn slint::Model>`](https://slint-ui.com/docs/rust/sixtyfps/trait.model). Since `memory_tiles` is an array in the `.slint` language, it is represented as a [`Rc<dyn slint::Model>`](https://slint-ui.com/docs/rust/slint/trait.model).
We can't modify the model generated by the .slint, but we can extract the tiles from it, and put it We can't modify the model generated by the .slint, but we can extract the tiles from it, and put it
in a [`VecModel`](https://slint-ui.com/docs/rust/sixtyfps/struct.vecmodel) which implements the `Model` trait. in a [`VecModel`](https://slint-ui.com/docs/rust/slint/struct.vecmodel) which implements the `Model` trait.
`VecModel` allows us to make modifications and we can use it to replace the static generated model. `VecModel` allows us to make modifications and we can use it to replace the static generated model.
We modify the main function like so: We modify the main function like so:

View file

@ -34,7 +34,7 @@ Insert this code before the `main_window.run()` call:
{{#include main_game_logic_in_rust.rs:game_logic}} {{#include main_game_logic_in_rust.rs:game_logic}}
``` ```
Notice that we take a [Weak](https://slint-ui.com/docs/rust/sixtyfps/struct.weak) pointer of our `main_window`. This is very Notice that we take a [Weak](https://slint-ui.com/docs/rust/slint/struct.weak) pointer of our `main_window`. This is very
important because capturing a copy of the `main_window` itself within the callback handler would result in a circular ownership. important because capturing a copy of the `main_window` itself within the callback handler would result in a circular ownership.
The `MainWindow` owns the callback handler, which itself owns a reference to the `MainWindow`, which must be weak The `MainWindow` owns the callback handler, which itself owns a reference to the `MainWindow`, which must be weak
instead of strong to avoid a memory leak. instead of strong to avoid a memory leak.

View file

@ -21,7 +21,7 @@ edition = "2021"
slint = "0.2.0" slint = "0.2.0"
``` ```
Finally we copy the hello world program from the [Slint documentation](https://slint-ui.com/docs/rust/sixtyfps/) into our `src/main.rs`: Finally we copy the hello world program from the [Slint documentation](https://slint-ui.com/docs/rust/slint/) into our `src/main.rs`:
```rust,noplayground ```rust,noplayground
{{#include main_initial.rs:main}} {{#include main_initial.rs:main}}

View file

@ -2,12 +2,12 @@
The game is visually a little bare. Here are some ideas how you could make further changes to enhance it: The game is visually a little bare. Here are some ideas how you could make further changes to enhance it:
* The tiles could have rounded corners, to look a little less sharp. The [border-radius](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#rectangle) * The tiles could have rounded corners, to look a little less sharp. The [border-radius](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#rectangle)
property of *Rectangle* can be used to achieve that. property of *Rectangle* can be used to achieve that.
* In real world memory games, the back of the tiles often have some common graphic. You could add an image with * In real world memory games, the back of the tiles often have some common graphic. You could add an image with
the help of another *[Image](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#image)* the help of another *[Image](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#image)*
element. Note that you may have to use *Rectangle*'s *[clip](https://slint-ui.com/docs/rust/sixtyfps/docs/builtin_elements/index.html#properties-1) property* element. Note that you may have to use *Rectangle*'s *[clip](https://slint-ui.com/docs/rust/slint/docs/builtin_elements/index.html#properties-1) property*
element around it to ensure that the image is clipped away when the curtain effect opens. element around it to ensure that the image is clipped away when the curtain effect opens.
Let us know in the comments on Github Discussions how you polished your code, or feel free to ask questions about Let us know in the comments on Github Discussions how you polished your code, or feel free to ask questions about