Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.
/ RSDE Public archive

Commit

Permalink
Add new cue pointer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Apr 5, 2019
1 parent c1e5aff commit 7ebfa8c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RSDE : Application() {

companion object {
const val TITLE = "RHRE SFX Database Editor"
val VERSION = Version(1, 0, 7, "")
val VERSION = Version(1, 1, 0, "DEVELOPMENT")
val rootFolder: File = File(System.getProperty("user.home")).resolve(".rsde/").apply { mkdirs() }
val rhreRoot: File = File(System.getProperty("user.home")).resolve(".rhre3/").apply {
mkdirs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
val fileExtField = TextField(struct.endingSound).apply {
this.promptText = SoundFileExtensions.DEFAULT.fileExt
}
val earlinessField = doubleSpinnerFactory(0.0, Float.MAX_VALUE.toDouble(), 0.0, 0.1)
val loopStartField = doubleSpinnerFactory(0.0, Float.MAX_VALUE.toDouble(), 0.0, 0.1)
val loopEndField = doubleSpinnerFactory(-1.0, Float.MAX_VALUE.toDouble(), -1.0, 0.1)
val responseIDsField = ChipPane(FXCollections.observableArrayList((struct.responseIDs ?: mutableListOf()).map { Chip(it) }))

init {
Expand All @@ -66,6 +69,15 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
tooltip = Tooltip().bindLocalized("cueObject.endingSound.tooltip")
}, endingSoundField)
addProperty(Label().bindLocalized("cueObject.fileExtension"), fileExtField)
addProperty(Label().bindLocalized("cueObject.earliness").apply {
tooltip = Tooltip().bindLocalized("cueObject.earliness.tooltip")
}, earlinessField)
addProperty(Label().bindLocalized("cueObject.loopStart").apply {
tooltip = Tooltip().bindLocalized("cueObject.loopStart.tooltip")
}, loopStartField)
addProperty(Label().bindLocalized("cueObject.loopEnd").apply {
tooltip = Tooltip().bindLocalized("cueObject.loopEnd.tooltip")
}, loopEndField)
addProperty(Label().bindLocalized("datamodel.responseIDs").apply {
tooltip = Tooltip().bindLocalized("datamodel.responseIDs.tooltip")
}, responseIDsField)
Expand All @@ -88,6 +100,7 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
loopsField.selectedProperty().addListener { _, _, newValue ->
struct.loops = newValue
editor.markDirty()
forceUpdate()
}
baseBpmField.valueProperty().addListener { _, _, newValue ->
struct.baseBpm = newValue.toFloat()
Expand All @@ -113,6 +126,18 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
struct.responseIDs = list.takeUnless { it.isEmpty() }
editor.markDirty()
})
earlinessField.valueProperty().addListener { _, _, n ->
struct.earliness = n.toFloat()
editor.markDirty()
}
loopStartField.valueProperty().addListener { _, _, n ->
struct.loopStart = n.toFloat()
editor.markDirty()
}
loopEndField.valueProperty().addListener { _, _, n ->
struct.loopEnd = n.toFloat()
editor.markDirty()
}

fileExtField.textProperty().addListener { _, _, _ ->
editor.refreshLists()
Expand All @@ -130,6 +155,15 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
durationField.valueProperty().addListener { _, _, _ ->
editor.refreshLists()
}
earlinessField.valueProperty().addListener { _, _, _ ->
editor.refreshLists()
}
loopStartField.valueProperty().addListener { _, _, _ ->
editor.refreshLists()
}
loopEndField.valueProperty().addListener { _, _, _ ->
editor.refreshLists()
}
}

init {
Expand All @@ -141,6 +175,8 @@ class CueObjPane(editor: Editor, struct: Cue) : DatamodelPane<Cue>(editor, struc
validation.registerValidators(endingSoundField, Validators.EXTERNAL_CUE_POINTER, Validators.cuePointerPointsNowhere(editor.gameObject))
validation.registerValidators(responseIDsField, Validators.EXTERNAL_RESPONSE_IDS, Validators.responseIDsPointsNowhere(editor.gameObject))
validation.registerValidators(durationField, Validators.ZERO_DURATION)
validation.registerValidators(loopStartField, Validators.loopStartAheadOfEnd(this), Validators.loopStartWithoutLooping(this))
validation.registerValidators(loopEndField, Validators.loopEndWithoutLooping(this))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.github.chrislo27.rhre3.sfxdb.SoundFileExtensions
import io.github.chrislo27.rhre3.sfxdb.adt.Cue
import io.github.chrislo27.rhre3.sfxdb.adt.Datamodel
import io.github.chrislo27.rhre3.sfxdb.adt.Game
import io.github.chrislo27.rhre3.sfxdb.gui.editor.panes.CueObjPane
import io.github.chrislo27.rhre3.sfxdb.gui.editor.panes.GameObjPane
import io.github.chrislo27.rhre3.sfxdb.gui.util.UiLocalization
import io.github.chrislo27.rhre3.sfxdb.validation.Transformers
Expand Down Expand Up @@ -145,6 +146,19 @@ object Validators {
fromErrorIf(t, UiLocalization["validation.zeroDuration"], u <= 0.0)
}

fun loopStartWithoutLooping(cueObjPane: CueObjPane): Validator<Double> = Validator { t, u ->
Validators.fromWarningIf(t, UiLocalization["validation.loopPointsWithoutLooping"]) { !cueObjPane.loopsField.isSelected && u > 0.0 }
}

fun loopEndWithoutLooping(cueObjPane: CueObjPane): Validator<Double> = Validator { t, u ->
Validators.fromWarningIf(t, UiLocalization["validation.loopPointsWithoutLooping"]) { !cueObjPane.loopsField.isSelected && u >= 0.0 }
}

fun loopStartAheadOfEnd(cueObjPane: CueObjPane): Validator<Double> = Validator { t, u ->
val loopEndValue = cueObjPane.loopEndField.value
Validators.fromErrorIf(t, UiLocalization["validation.loopStartAheadOfEnd"]) { loopEndValue >= 0.0 && u > loopEndValue }
}

// MultipartObject
val ZERO_DISTANCE: Validator<Double> = Validator { t, u ->
fromErrorIf(t, UiLocalization["validation.zeroDistance"], u <= 0.0)
Expand Down
8 changes: 8 additions & 0 deletions gui/src/main/resources/localization/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ cueObject.introSound.tooltip=The pointer ID for another sound to play when this
cueObject.endingSound=Ending sound:
cueObject.endingSound.tooltip=The pointer ID for another sound to play when this cue ends
cueObject.fileExtension=File extension:
cueObject.earliness=Earliness:
cueObject.earliness.tooltip=The amount of seconds early to play this cue
cueObject.loopStart=Loop start:
cueObject.loopStart.tooltip=Where to start the loop in seconds
cueObject.loopEnd=Loop end:
cueObject.loopEnd.tooltip=Where to end the loop in seconds. Negative values indicate the entire sound file length

equidistantObj.distance=Distance
equidistantObj.distance.tooltip=The distance between each cue (end-to-end)
Expand Down Expand Up @@ -165,3 +171,5 @@ validation.abnormalSemitone=The semitone value is out of the standard RHRE range
validation.zeroDuration=The duration must be greater than zero
validation.zeroDistance=The distance must be greater than zero
validation.unsupportedFileExt=File extension is not supported. Use {0} or leave blank
validation.loopPointsWithoutLooping=The "loops" field isn't true, but this field is positive
validation.loopStartAheadOfEnd=The loop start is after the loop end. Move the loop start back, or set the loop end to -1.0
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ class Cue(
@JsonInclude(JsonInclude.Include.NON_EMPTY) var endingSound: String? = null,
@JsonInclude(JsonInclude.Include.NON_EMPTY) var responseIDs: MutableList<String>? = null,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var baseBpm: Float = 0f,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var loops: Boolean = false
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var loops: Boolean = false,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var earliness: Float = 0f,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var loopStart: Float = 0f,
@JsonInclude(JsonInclude.Include.NON_DEFAULT) var loopEnd: Float = -1f
) : Datamodel("cue", id, name, deprecatedIDs) {
override fun copy(): Datamodel {
return Cue(id, name, deprecatedIDs, duration, stretchable, repitchable, fileExtension, introSound, endingSound, responseIDs?.toMutableList(), baseBpm, loops)
return Cue(id, name, deprecatedIDs, duration, stretchable, repitchable, fileExtension, introSound, endingSound, responseIDs?.toMutableList(), baseBpm, loops, earliness, loopStart, loopEnd)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,25 @@ class CueObject : DatamodelObject() {
var introSound: Result<String> by Property(Transformers.idTransformer, "")
var endingSound: Result<String> by Property(Transformers.idTransformer, "")
var responseIDs: Result<MutableList<String>> by Property(Transformers.responseIDsTransformer, mutableListOf())
var earliness: Result<Float> by Property(Transformers.positiveFloatTransformer("Earliness must be positive"), 0f)
var loopStart: Result<Float> by Property(Transformers.positiveFloatTransformer("Loop start must be positive"), 0f)
var loopEnd: Result<Float> by Property(Transformers.floatTransformer, -1f)

override fun producePerfectADT(): Cue {
return Cue(
id.orException(), name.orException(), deprecatedIDs.orException(), duration.orException(),
stretchable.orException(), repitchable.orException(), fileExtension.orException(), introSound.orException(),
endingSound.orException(), responseIDs.orException(), baseBpm.orException(), loops.orException()
endingSound.orException(), responseIDs.orException(), baseBpm.orException(), loops.orException(),
earliness.orException(), loopStart.orException(), loopEnd.orException()
)
}

override fun produceImperfectADT(): Cue {
return Cue(
id.orElse(""), name.orElse(""), deprecatedIDs.orElse(mutableListOf()), duration.orElse(0f),
stretchable.orElse(false), repitchable.orElse(false), fileExtension.orElse(""), introSound.orNull(),
endingSound.orNull(), responseIDs.orNull(), baseBpm.orElse(0f), loops.orElse(false)
endingSound.orNull(), responseIDs.orNull(), baseBpm.orElse(0f), loops.orElse(false),
earliness.orElse(0f), loopStart.orElse(0f), loopEnd.orElse(-1f)
)
}
}
Expand Down

0 comments on commit 7ebfa8c

Please sign in to comment.