generated from stonecutter-versioning/stonecutter-template-fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
271 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,5 @@ | ||
## Resource pack sounds (AKA sound packs) | ||
This update allows packaging sounds as resource packs to share them with other players. | ||
## Woah new update in less than a day | ||
|
||
In your resource pack add `.wav` files in `assets/<namespace>/soundboard`. | ||
You can create any subdirectories inside to organize files or | ||
create other namespaces to override other sounds. | ||
Created subdirectories will form collapsible groups in the soundboard menu. | ||
|
||
By default, provided sounds won't look pretty. | ||
You need to provide a translation key for them. | ||
Translations are stored in `assets/<namespace>/lang`. | ||
The default language is `en_us.json`. | ||
|
||
Category names are prefixed with `soundboard.dir.<namespace>`. | ||
For example, if you have a file in `assets/mysoundpack/soundboard/scary/ghost_boo.wav`, | ||
you'll have the following translation file: | ||
```json | ||
{ | ||
"soundboard.dir.mysoundpack": "My first sound pack!", | ||
"soundboard.dir.mysoundpack.scary": "Spooky sounds", | ||
"soundboard.file.mysoundpack.scary.ghost_boo": "Very scary ghost sound" | ||
} | ||
``` | ||
|
||
You can see the example sound pack in the [Soundboard repository](https://github.com/kikugie/voicechat-soundboard/tree/multiaddon/src/main/resources/resourcepacks/default). | ||
Translation files also support [OwO-lib rich translations](https://docs.wispforest.io/owo/rich-translations/) | ||
|
||
## Translatable local sounds | ||
You still can put `.wav` files in `.minecraft/config/soundboard`, | ||
but this update allows you to customize their appearance. | ||
|
||
To provide a sound name, put a `<filename>.properties` in its directory. | ||
For the category name put a `.properties` file inside it. | ||
|
||
Property files follow the [Java properties format](https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0204propertiesfileformat01.html), but only the `title` field matters. | ||
|
||
For example, if you have the sound `.minecraft/config/soundboard/scary/ghost_boo.wav`, | ||
you use these files: | ||
|
||
```properties | ||
# .minecraft/config/soundboard/scary/.properties | ||
title=Spooky sounds | ||
``` | ||
|
||
```properties | ||
# .minecraft/config/soundboard/scary/ghost_boo.properties | ||
title=Very scary ghost sound | ||
``` | ||
|
||
## Audio editor | ||
Ctrl-click on any sound to bring up the editor: | ||
![Editor GUI](https://i.imgur.com/lpIdP65.png) | ||
|
||
The audio editor allows you to cut the duration of the sound and modify the volume. | ||
You can also use play button in the corner to play it locally. | ||
(Others won't hear it, unless you have bad noise suppression) | ||
|
||
The audio editor doesn't modify the original file and saves changes when closed, | ||
so you can bring it up again to adjust the values. | ||
This fixes a bug in 0.4, where sounds would play for half the length. | ||
It also comes with a new feature: favourite sounds. | ||
![Favourites](https://i.imgur.com/7o89tD5.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
src/main/kotlin/dev/kikugie/soundboard/audio/SoundEntry.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
package dev.kikugie.soundboard.audio | ||
|
||
import dev.kikugie.kowoui.translation | ||
import net.minecraft.text.Text | ||
import java.io.InputStream | ||
|
||
data class SoundEntry( | ||
val name: String, | ||
val path: String, | ||
val supplier: () -> InputStream, | ||
val title: String? = null, | ||
var settings: AudioConfiguration? = null | ||
private val _title: String? = null, | ||
var settings: AudioConfiguration? = null, | ||
) { | ||
val id: SoundId by lazy { SoundId("$path/$name") } | ||
|
||
fun title() = title?.translation() ?: run { | ||
var (namespace, path) = SoundRegistry.splitPath(path) | ||
path += ".$name" | ||
if (path.startsWith('.')) path = path.drop(1) | ||
"soundboard.file.$namespace.$path".translation(name) | ||
val title: Text by lazy { | ||
_title?.translation() ?: run { | ||
var (namespace, path) = SoundRegistry.splitPath(path) | ||
path += ".$name" | ||
if (path.startsWith('.')) path = path.drop(1) | ||
"soundboard.file.$namespace.$path".translation(name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
package dev.kikugie.soundboard.audio | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@JvmInline | ||
@Serializable | ||
value class SoundId(val str: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package dev.kikugie.soundboard.gui | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem | ||
import net.minecraft.client.MinecraftClient | ||
import dev.kikugie.soundboard.util.currentScreen | ||
import net.minecraft.client.gui.screen.Screen | ||
import kotlin.reflect.KClass | ||
import kotlin.reflect.full.createInstance | ||
|
||
abstract class ScreenManager(private val cls: KClass<out Screen>) { | ||
fun open() = RenderSystem.recordRenderCall { MinecraftClient.getInstance().setScreen(cls.createInstance()) } | ||
fun close() = MinecraftClient.getInstance().currentScreen?.let { if (it::class == cls) it.close() } | ||
fun open() = RenderSystem.recordRenderCall { currentScreen = cls.createInstance() } | ||
fun close() = currentScreen?.let { if (it::class == cls) it.close() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/dev/kikugie/soundboard/gui/component/DynamicButtonComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dev.kikugie.soundboard.gui.component | ||
|
||
import dev.kikugie.kowoui.text | ||
import io.wispforest.owo.ui.component.ButtonComponent | ||
import net.minecraft.text.Text | ||
|
||
abstract class DynamicButtonComponent : ButtonComponent(Text.empty(), {}) { | ||
private var _text: Text = Text.empty() | ||
private var _string: String = "" | ||
abstract val string: String | ||
|
||
override fun getMessage(): Text { | ||
if (string != _string) { | ||
_string = string | ||
_text = string.text() | ||
} | ||
return _text | ||
} | ||
} |
Oops, something went wrong.