Skip to content

Commit

Permalink
i can't remember my own syntax lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
LichtHund committed Oct 21, 2024
1 parent 7044f91 commit 80bc9f3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions triumph-gui/4_x_x/1-started/creating-gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ setting custom [renderer](/renderer)s.

Let's create a GUI with a `1` row and an item the middle that sends the `player` a message when clicking.

-+-
+Java+
-+-
+Java+

```java
final var gui = Gui.of(1)
Expand All @@ -40,7 +40,7 @@ final var gui = Gui.of(1)
gui.open(player);
```
+++
+Kotlin+
+Kotlin+
```kotlin
val gui = buildGui {
// If not set, defaults to chest - 1 row
Expand All @@ -64,8 +64,8 @@ val gui = buildGui {
// Now that the GUI is built, we can open it for the player.
gui.open(player)
```
+++
-+-
+++
-+-

Now that the GUI is created, we can dive into something more complex by utilizing [States](/states).
We can continue onto the next example [here](/using-states).
36 changes: 18 additions & 18 deletions triumph-gui/4_x_x/1-started/updating-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ command class.
For this state it's nice to make it so it can only be updated if the clicks are higher than the stored value. Thankfully
we can use a [StateMutationPolicy](/mutation-policy) for that, so let's create a new one!

-+-
+Java+
-+-
+Java+

```java
public final class HighScoreMutationPolicy implements StateMutationPolicy<Integer> {
Expand All @@ -38,8 +38,8 @@ public final class HighScoreMutationPolicy implements StateMutationPolicy<Intege
}
}
```
+++
+Kotlin+
+++
+Kotlin+

```kotlin
class HighScoreMutationPolicy : StateMutationPolicy<Int?> {
Expand All @@ -51,33 +51,33 @@ class HighScoreMutationPolicy : StateMutationPolicy<Int?> {
}
}
```
+++
-+-
+++
-+-

_The mutation policy in this example is not really needed; this is just an example of how it can be used._

Now let's create a state with the new policy.

-+-
+Java+
-+-
+Java+

```java
private final MutableState<Integer> highScoreState = MutableState.of(0, new HighScoreMutationPolicy());
```

+++
+Kotlin+
+++
+Kotlin+

```kotlin
private val highScoreState = mutableStateOf(0, HighScoreMutationPolicy())
```
+++
-+-
+++
-+-

Then we can change the GUI to support it.

-+-
+Java+
-+-
+Java+

```java
final var gui = Gui.of(1)
Expand Down Expand Up @@ -122,8 +122,8 @@ final var gui = Gui.of(1)

gui.open(player);
```
+++
+Kotlin+
+++
+Kotlin+

```kotlin
val gui = buildGui {
Expand Down Expand Up @@ -177,8 +177,8 @@ val gui = buildGui {

gui.open(player)
```
+++
-+-
+++
-+-

When the GUI is opened for the first time the title will update with the clicks, once you close and re-open it, it'll
only update once you reach a new high score.
Expand Down
12 changes: 6 additions & 6 deletions triumph-gui/4_x_x/1-started/using-states.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ modifier cause the component to re-render.
Let's take the previous example and add some a state to it. We can create a state that'll keep track of how many times
a `player` has clicked on the item.

-+-
+Java+
-+-
+Java+

```java
final var gui = Gui.of(1)
Expand Down Expand Up @@ -51,8 +51,8 @@ final var gui = Gui.of(1)
gui.open(player);
```

+++
+Kotlin+
+++
+Kotlin+
```kotlin
val gui = buildGui {
// If not set, defaults to chest - 1 row
Expand Down Expand Up @@ -87,7 +87,7 @@ val gui = buildGui {

gui.open(player)
```
+++
-+-
+++
-+-
Congratulations you have built the most simple cookie clicker game!
But we can improve it even more, let's add title updating into the mix, read more in [here](/updating-title).

0 comments on commit 80bc9f3

Please sign in to comment.