Skip to content

Commit

Permalink
Add tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
CedNaru committed Oct 5, 2024
1 parent fdc40e6 commit 528c74f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ markdown_extensions:
- pymdownx.inlinehilite
- pymdownx.highlight
- pymdownx.superfences
- pymdownx.tabbed
- pymdownx.blocks.tab
- pymdownx.details
- admonition
- meta
Expand Down
6 changes: 4 additions & 2 deletions docs/src/doc/getting-started/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ If the user does not want to use our IntelliJ IDEA plugin, then they can follow
Firstly, you need to setup a Gradle [wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html).
The wrapper will ensure that anyone who wants to build your project from source will use the same Gradle version.

=== "Windows"
/// tab | "Windows"
```shell
fsutil file createnew build.gradle.kts 0
fsutil file createnew gradle.properties 0
fsutil file createnew settings.gradle.kts 0
```
///

=== "Unix"
/// tab | "Unix"
```shell
touch build.gradle.kts gradle.properties settings.gradle.kts
```
///

The above command(s) will create three empty files. As next step, type the following
command on the terminal:
Expand Down
12 changes: 8 additions & 4 deletions docs/src/doc/user-guide/api-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,33 +173,37 @@ It's often more convenient to directly use a String and convert it.

This kind of operation can be costly so we provide extension functions which cache the result of the conversion for later calls:

=== "Kotlin"
/// tab | "Kotlin"
```kotlin
val stringName = "myString".asCachedStringName() // Cache the string for faster future calls.
val nodePath = "myNode/myChildNode".asCachedNodePath() // Cache the string for faster future calls.
val snakeCaseStringName = "myString".toGodotName() // Convert the string to snake_case and cache it for faster future calls.
```
///

=== "Java"
/// tab | "Java"
```java
StringName stringName = StringNames.asCachedStringName("myString");
NodePath nodePath = NodePaths.asCachedNodePath("myNode/myChildNode");
StringName snakeCaseStringName = StringNames.toGodotName("myString");
```
///

You can also use the non-cached version of them if you simply want ease of conversion:

=== "Kotlin"
/// tab | "Kotlin"
```kotlin
val stringName = "myString".asStringName()
val nodePath = "myNode/myChildNode".asNodePath()
```
///

=== "Java"
/// tab | "Java"
```java
StringName stringName = StringNames.asStringName("myString");
NodePath nodePath = NodePaths.asNodePath("myNode/myChildNode");
```
///


## Logging
Expand Down
24 changes: 16 additions & 8 deletions docs/src/doc/user-guide/signals_and_callables.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Signals are not stateful so it's usually a waste to store them directly per inst

In both case, you have to provide the name of the signal parameters as strings for the registration to Godot.

=== "Kotlin"
/// tab | "Kotlin"
```kotlin
@RegisterClass
class MyScript: Node() {
Expand All @@ -23,15 +23,17 @@ class MyScript: Node() {
val mySignal = Signal1<Boolean>("mySignal", "reverse")
}
```
///

=== "Java"
/// tab | "Java"
```java
@RegisterClass
public MyScript extends Node {
@RegisterSignal
public Signal1<Boolean> mySignal = Signal1.create(this, "mySignal", "reverse"); // Only one way to do it in Java.
}
```
///

!!! warning Signal parameter count
In GDScript, signals can have any number of arguments, this is not possible in Kotlin as it is a statically typed language.
Expand All @@ -41,28 +43,31 @@ public MyScript extends Node {

Every signal has a `emit` method which can be used to emit it in a type-safe way.

=== "Kotlin"
/// tab | "Kotlin"
```kotlin
reverseChanged.emit(false)
```
///

=== "Java"
/// tab | "Java"
```java
reverseChanged.emit(false);
```
///

## Callables

You can use a classic Callable referencing a Godot Object and one of its method or conveniently use to avoid to creating a separate function.


=== "Kotlin"
/// tab | "Kotlin"
```kotlin
val regularCallable = NativeCallable(myObject, MyObject::myMethod)
val customCallable = callable1<String> { prinln(it) }
```
///

=== "Java"
/// tab | "Java"
```java
NativeCallable regularCallable = Callables.create(myObject, "myMethod".toGodotName());
LambdaCallable1<Void, String> customCallable = LambdaCallable1.create(
Expand All @@ -73,6 +78,7 @@ You can use a classic Callable referencing a Godot Object and one of its method
}
);
```
///

### Signals and Callables together

Expand All @@ -82,7 +88,7 @@ In that context and unlike GDScript, the only reason you want to use a Callable
A method can be subscribed/connected to a signal via `connect` using a function reference or a StringName of the method you want to call.
Note that the connected method has to be a registered to Godot.

=== "Kotlin"
/// tab | "Kotlin"
```kotlin
@RegisterClass
class SomeObject: Object() {
Expand All @@ -105,8 +111,9 @@ class AnotherObject: Object() {
}
}
```
///

=== "Java"
/// tab | "Java"
```java
@RegisterClass
public class SomeObject extends Object {
Expand All @@ -129,6 +136,7 @@ public class AnotherObject extends Object {
}
}
```
///

You can also use Kotlin lambdas directly to subscribe to signals

Expand Down

0 comments on commit 528c74f

Please sign in to comment.