mirror of
https://github.com/RDCN-Community-Developers/rdkt.git
synced 2026-09-05 01:35:31 +08:00
Moved SyncoSettings and SyncoStyle.
This commit is contained in:
@@ -0,0 +1,83 @@
|
|||||||
|
package cn.rdlevel.rdkt.core.data
|
||||||
|
|
||||||
|
import kotlin.jvm.JvmStatic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the synco settings of a row. It can either be [Disabled] or [Enabled], where [Enabled] allows for further customization of the synco settings such as beat, swing, volume, pitch, and style.
|
||||||
|
*/
|
||||||
|
public sealed interface SyncoSettings {
|
||||||
|
public val beat: Int
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The synco beat is disabled.
|
||||||
|
*/
|
||||||
|
public object Disabled : SyncoSettings {
|
||||||
|
override val beat: Int = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The synco beat is enabled.
|
||||||
|
*/
|
||||||
|
public class Enabled : SyncoSettings {
|
||||||
|
/**
|
||||||
|
* The beat where the synco is active. It must be between 0 and 5, where 0 is the first beat.
|
||||||
|
*
|
||||||
|
* If you just want to disable the synco beat, consider use [SyncoSettings.Disabled] instead.
|
||||||
|
*/
|
||||||
|
override var beat: Int = 0
|
||||||
|
set(value) {
|
||||||
|
require(value in 0..5) { "Synco beat must be between 0 and 5, but found: $value." }
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reduced percentage of the [cn.rdlevel.rdkt.core.events.AddClassicBeatEvent.tick] on the synco [beat]. It must be between 0.0 and 1.0. Setting this to 0 will use the default 50% reduction.
|
||||||
|
*/
|
||||||
|
public var swing: Double = 0.0
|
||||||
|
set(value) {
|
||||||
|
require(value in 0.0..1.0) { "Synco swing must be between 0.0 and 1.0, but found: $value." }
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The volume of the synco sound. It must be between 0 and 200.
|
||||||
|
*/
|
||||||
|
public var volume: Int = 70
|
||||||
|
set(value) {
|
||||||
|
require(value in 0..200) { "Synco volume must be between 0 and 200, but found: $value." }
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pitch of the synco sound. It must be between 0 and 200.
|
||||||
|
*/
|
||||||
|
public var pitch: Int = 100
|
||||||
|
set(value) {
|
||||||
|
require(value in 0..200) { "Synco volume must be between 0 and 200, but found: $value." }
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The style of the synco sound.
|
||||||
|
*/
|
||||||
|
public var style: SyncoStyle = SyncoStyle.Chirp()
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
/**
|
||||||
|
* Creates a [SyncoSettings] with the synco beat disabled.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
public fun disabled(): Disabled = Disabled
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [SyncoSettings] with the synco beat enabled and configures with the provided [block].
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
public fun enabled(block: Enabled.() -> Unit): Enabled {
|
||||||
|
val enabled = Enabled()
|
||||||
|
enabled.block()
|
||||||
|
return enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package cn.rdlevel.rdkt.core.data
|
||||||
|
|
||||||
|
import kotlin.jvm.JvmStatic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the style of the synco sound.
|
||||||
|
*/
|
||||||
|
public sealed class SyncoStyle(public val style: String) {
|
||||||
|
/**
|
||||||
|
* The chirp style.
|
||||||
|
*
|
||||||
|
* @property playModifierSound Whether to play sound when the synco is turned on. Default is true.
|
||||||
|
* @property playModifierOffSound Whether to play sound when the synco is turned off. Default is true.
|
||||||
|
*/
|
||||||
|
public data class Chirp(
|
||||||
|
var playModifierSound: Boolean = true,
|
||||||
|
var playModifierOffSound: Boolean = true,
|
||||||
|
) : SyncoStyle("Chirp")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The beep style.
|
||||||
|
*/
|
||||||
|
public data object Beep : SyncoStyle("Beep")
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
/**
|
||||||
|
* Creates a [SyncoStyle] with the chirp style and configures with the provided parameters.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
public fun chirp(
|
||||||
|
playModifierSound: Boolean = true,
|
||||||
|
playModifierOffSound: Boolean = true,
|
||||||
|
): Chirp = Chirp(playModifierSound, playModifierOffSound)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [SyncoStyle] with the beep style.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
public fun beep(): Beep = Beep
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,16 +5,17 @@ package cn.rdlevel.rdkt.core.events
|
|||||||
|
|
||||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||||
import cn.rdlevel.rdkt.core.data.RowPattern
|
import cn.rdlevel.rdkt.core.data.RowPattern
|
||||||
|
import cn.rdlevel.rdkt.core.data.SyncoSettings
|
||||||
|
import cn.rdlevel.rdkt.core.data.SyncoStyle
|
||||||
import cn.rdlevel.rdkt.core.serialization.TransformSerializer
|
import cn.rdlevel.rdkt.core.serialization.TransformSerializer
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.jvm.JvmStatic
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the row pattern and synco settings for a row.
|
* Sets the row pattern and synco settings for a row.
|
||||||
*
|
*
|
||||||
* @property pattern The [RowPattern] representing the pulse pattern of the row.
|
* @property pattern The [RowPattern] representing the pulse pattern of the row.
|
||||||
* @property synco The [SyncoSettings] representing the synco settings of the row.
|
* @property synco The [cn.rdlevel.rdkt.core.data.SyncoSettings] representing the synco settings of the row.
|
||||||
*/
|
*/
|
||||||
@Serializable(SetRowXsEvent.Serializer::class)
|
@Serializable(SetRowXsEvent.Serializer::class)
|
||||||
@SerialName("SetRowXs")
|
@SerialName("SetRowXs")
|
||||||
@@ -22,124 +23,6 @@ public data class SetRowXsEvent(
|
|||||||
var pattern: RowPattern = RowPattern(),
|
var pattern: RowPattern = RowPattern(),
|
||||||
var synco: SyncoSettings = SyncoSettings.Disabled,
|
var synco: SyncoSettings = SyncoSettings.Disabled,
|
||||||
) : RowEvent() {
|
) : RowEvent() {
|
||||||
/**
|
|
||||||
* Represents the synco settings of a row. It can either be [Disabled] or [Enabled], where [Enabled] allows for further customization of the synco settings such as beat, swing, volume, pitch, and style.
|
|
||||||
*/
|
|
||||||
public sealed interface SyncoSettings {
|
|
||||||
public val beat: Int
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The synco beat is disabled.
|
|
||||||
*/
|
|
||||||
public object Disabled : SyncoSettings {
|
|
||||||
override val beat: Int = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The synco beat is enabled.
|
|
||||||
*/
|
|
||||||
public class Enabled : SyncoSettings {
|
|
||||||
/**
|
|
||||||
* The beat where the synco is active. It must be between 0 and 5, where 0 is the first beat.
|
|
||||||
*
|
|
||||||
* If you just want to disable the synco beat, consider use [SyncoSettings.Disabled] instead.
|
|
||||||
*/
|
|
||||||
override var beat: Int = 0
|
|
||||||
set(value) {
|
|
||||||
require(value in 0..5) { "Synco beat must be between 0 and 5, but found: $value." }
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The reduced percentage of the [AddClassicBeatEvent.tick] on the synco [beat]. It must be between 0.0 and 1.0. Setting this to 0 will use the default 50% reduction.
|
|
||||||
*/
|
|
||||||
public var swing: Double = 0.0
|
|
||||||
set(value) {
|
|
||||||
require(value in 0.0..1.0) { "Synco swing must be between 0.0 and 1.0, but found: $value." }
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The volume of the synco sound. It must be between 0 and 200.
|
|
||||||
*/
|
|
||||||
public var volume: Int = 70
|
|
||||||
set(value) {
|
|
||||||
require(value in 0..200) { "Synco volume must be between 0 and 200, but found: $value." }
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The pitch of the synco sound. It must be between 0 and 200.
|
|
||||||
*/
|
|
||||||
public var pitch: Int = 100
|
|
||||||
set(value) {
|
|
||||||
require(value in 0..200) { "Synco volume must be between 0 and 200, but found: $value." }
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The style of the synco sound.
|
|
||||||
*/
|
|
||||||
public var style: SyncoStyle = SyncoStyle.Chirp()
|
|
||||||
}
|
|
||||||
|
|
||||||
public companion object {
|
|
||||||
/**
|
|
||||||
* Creates a [SyncoSettings] with the synco beat disabled.
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
public fun disabled(): Disabled = Disabled
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a [SyncoSettings] with the synco beat enabled and configures with the provided [block].
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
public fun enabled(block: Enabled.() -> Unit): Enabled {
|
|
||||||
val enabled = Enabled()
|
|
||||||
enabled.block()
|
|
||||||
return enabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the style of the synco sound.
|
|
||||||
*/
|
|
||||||
public sealed class SyncoStyle(public val style: String) {
|
|
||||||
/**
|
|
||||||
* The chirp style.
|
|
||||||
*
|
|
||||||
* @property playModifierSound Whether to play sound when the synco is turned on. Default is true.
|
|
||||||
* @property playModifierOffSound Whether to play sound when the synco is turned off. Default is true.
|
|
||||||
*/
|
|
||||||
public data class Chirp(
|
|
||||||
var playModifierSound: Boolean = true,
|
|
||||||
var playModifierOffSound: Boolean = true,
|
|
||||||
) : SyncoStyle("Chirp")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The beep style.
|
|
||||||
*/
|
|
||||||
public data object Beep : SyncoStyle("Beep")
|
|
||||||
|
|
||||||
public companion object {
|
|
||||||
/**
|
|
||||||
* Creates a [SyncoStyle] with the chirp style and configures with the provided parameters.
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
public fun chirp(
|
|
||||||
playModifierSound: Boolean = true,
|
|
||||||
playModifierOffSound: Boolean = true,
|
|
||||||
): Chirp = Chirp(playModifierSound, playModifierOffSound)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a [SyncoStyle] with the beep style.
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
public fun beep(): Beep = Beep
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Serializer : TransformSerializer<SetRowXsEvent, Serializer.Data>("SetRowXs", Data.serializer()) {
|
public object Serializer : TransformSerializer<SetRowXsEvent, Serializer.Data>("SetRowXs", Data.serializer()) {
|
||||||
override fun toData(value: SetRowXsEvent): Data {
|
override fun toData(value: SetRowXsEvent): Data {
|
||||||
return Data.fromBase(value).apply {
|
return Data.fromBase(value).apply {
|
||||||
|
|||||||
Reference in New Issue
Block a user