Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/bugfix/74-spine-beta-sup…
Browse files Browse the repository at this point in the history
…port' into develop
  • Loading branch information
DanielSWolf committed Jul 17, 2019
2 parents 460378b + 5fcc881 commit e57fc97
Show file tree
Hide file tree
Showing 31 changed files with 528 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* **Added** switch data file exporter for Moho (formerly Anime Studio) and OpenToonz ([issue #69](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/69))
* **Added** support for Spine 3.8 beta ([issue #74](https://github.com/DanielSWolf/rhubarb-lip-sync/issues/74))
* **Improved** animation rule for OW sound: animating it as E-F rather than F.

## Version 1.9.1
Expand Down
2 changes: 1 addition & 1 deletion extras/EsotericSoftwareSpine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.2)

add_custom_target(
rhubarbForSpine ALL
"./gradlew" "jar"
"./gradlew" "shadowJar"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building Rhubarb for Spine through Gradle."
)
Expand Down
56 changes: 0 additions & 56 deletions extras/EsotericSoftwareSpine/build.gradle

This file was deleted.

55 changes: 55 additions & 0 deletions extras/EsotericSoftwareSpine/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
kotlin("jvm") version "1.3.41"
id("com.github.johnrengelman.shadow") version "5.1.0"
}

fun getVersion(): String {
// Dynamically read version from CMake file
val file = File(rootDir.parentFile.parentFile, "appInfo.cmake")
val text = file.readText()
val major = Regex("""appVersionMajor\s+(\d+)""").find(text)!!.groupValues[1]
val minor = Regex("""appVersionMinor\s+(\d+)""").find(text)!!.groupValues[1]
val patch = Regex("""appVersionPatch\s+(\d+)""").find(text)!!.groupValues[1]
val suffix = Regex("""appVersionSuffix\s+"(.*?)"""").find(text)!!.groupValues[1]
return "$major.$minor.$patch$suffix"
}

group = "com.rhubarb_lip_sync"
version = getVersion()

repositories {
mavenCentral()
jcenter()
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.beust:klaxon:5.0.1")
implementation("org.apache.commons:commons-lang3:3.9")
implementation("no.tornado:tornadofx:1.7.19")
testImplementation("org.junit.jupiter:junit-jupiter:5.5.0")
testCompile("org.assertj:assertj-core:3.11.1")
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

tasks.test {
useJUnitPlatform()
}

tasks.shadowJar {
dependsOn(tasks.test)

// Modified by shadow plugin
archiveClassifier.set(null as String?)

manifest {
attributes("Main-Class" to "com.rhubarb_lip_sync.rhubarb_for_spine.MainKt")
}
}
Binary file modified extras/EsotericSoftwareSpine/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 0 additions & 2 deletions extras/EsotericSoftwareSpine/settings.gradle

This file was deleted.

1 change: 1 addition & 0 deletions extras/EsotericSoftwareSpine/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "rhubarb-for-spine"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import javafx.beans.property.SimpleListProperty
import javafx.beans.property.SimpleObjectProperty
import javafx.beans.property.SimpleStringProperty
import javafx.collections.ObservableList
import tornadofx.asObservable
import java.nio.file.Path
import tornadofx.getValue
import tornadofx.observable
Expand Down Expand Up @@ -61,7 +62,7 @@ class AnimationFileModel(val parentModel: MainModel, animationFilePath: Path, pr
audioFileModel = AudioFileModel(event, this, executor, reportResult)
return@map audioFileModel
}
.observable()
.asObservable()
)
val audioFileModels: ObservableList<AudioFileModel> by audioFileModelsProperty

Expand Down Expand Up @@ -97,7 +98,7 @@ class AnimationFileModel(val parentModel: MainModel, animationFilePath: Path, pr
}

init {
slots = spineJson.slots.observable()
slots = spineJson.slots.asObservable()
mouthSlot = spineJson.guessMouthSlot()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class MainView : View() {
placeholder = Label("There are no events with associated audio files.")
columnResizePolicy = SmartResize.POLICY
column("Event", AudioFileModel::eventNameProperty)
.weigthedWidth(1.0)
.weightedWidth(1.0)
column("Animation name", AudioFileModel::animationNameProperty)
.weigthedWidth(1.0)
.weightedWidth(1.0)
column("Audio file", AudioFileModel::displayFilePathProperty)
.weigthedWidth(1.0)
.weightedWidth(1.0)
column("Dialog", AudioFileModel::dialogProperty).apply {
weigthedWidth(3.0)
weightedWidth(3.0)
// Make dialog column wrap
setCellFactory { tableColumn ->
return@setCellFactory TableCell<AudioFileModel, String>().also { cell ->
Expand All @@ -138,7 +138,7 @@ class MainView : View() {
}
}
column("Status", AudioFileModel::audioFileStateProperty).apply {
weigthedWidth(1.0)
weightedWidth(1.0)
setCellFactory {
return@setCellFactory object : TableCell<AudioFileModel, AudioFileState>() {
override fun updateItem(state: AudioFileState?, empty: Boolean) {
Expand Down Expand Up @@ -176,7 +176,7 @@ class MainView : View() {
}
}
column("", AudioFileModel::actionLabelProperty).apply {
weigthedWidth(1.0)
weightedWidth(1.0)
// Show button
setCellFactory {
return@setCellFactory object : TableCell<AudioFileModel, String>() {
Expand Down Expand Up @@ -254,4 +254,4 @@ class MainView : View() {
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.rhubarb_lip_sync.rhubarb_for_spine

import com.beust.klaxon.JsonObject
import com.beust.klaxon.array
import com.beust.klaxon.double
import com.beust.klaxon.string
import com.beust.klaxon.Parser as JsonParser
import org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS
import java.io.*
Expand Down Expand Up @@ -78,7 +75,7 @@ class RhubarbTask(
}
}

private val jsonParser = JsonParser()
private val jsonParser = JsonParser.default()
private fun parseJsonObject(jsonString: String): JsonObject {
return jsonParser.parse(StringReader(jsonString)) as JsonObject
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ class SpineJson(private val filePath: Path) {
throw EndUserException("File '$filePath' does not exist.")
}
try {
json = Parser().parse(filePath.toString()) as JsonObject
json = Parser.default().parse(filePath.toString()) as JsonObject
} catch (e: Exception) {
throw EndUserException("Wrong file format. This is not a valid JSON file.")
}
skeleton = json.obj("skeleton") ?: throw EndUserException("JSON file is corrupted.")
val skins = json.obj("skins") ?: throw EndUserException("JSON file doesn't contain skins.")
defaultSkin = skins.obj("default") ?: throw EndUserException("JSON file doesn't have a default skin.")
val skins = json["skins"] ?: throw EndUserException("JSON file doesn't contain skins.")
defaultSkin = when (skins) {
is JsonObject -> skins.obj("default")
is JsonArray<*> -> (skins as JsonArray<JsonObject>).find { it.string("name") == "default" }
else -> null
} ?: throw EndUserException("JSON file doesn't have a default skin.")

validateProperties()
}

Expand All @@ -35,7 +40,7 @@ class SpineJson(private val filePath: Path) {
private val imagesDirectoryPath: Path get() {
val relativeImagesDirectory = skeleton.string("images")
?: throw EndUserException("JSON file is incomplete: Images path is missing."
+ "Make sure to check 'Nonessential data' when exporting.")
+ " Make sure to check 'Nonessential data' when exporting.")

val imagesDirectoryPath = fileDirectoryPath.resolve(relativeImagesDirectory).normalize()
if (!Files.exists(imagesDirectoryPath)) {
Expand All @@ -49,7 +54,7 @@ class SpineJson(private val filePath: Path) {
val audioDirectoryPath: Path get() {
val relativeAudioDirectory = skeleton.string("audio")
?: throw EndUserException("JSON file is incomplete: Audio path is missing."
+ "Make sure to check 'Nonessential data' when exporting.")
+ " Make sure to check 'Nonessential data' when exporting.")

val audioDirectoryPath = fileDirectoryPath.resolve(relativeAudioDirectory).normalize()
if (!Files.exists(audioDirectoryPath)) {
Expand Down Expand Up @@ -91,7 +96,9 @@ class SpineJson(private val filePath: Path) {
}

fun getSlotAttachmentNames(slotName: String): List<String> {
val attachments = defaultSkin.obj(slotName) ?: JsonObject()
val attachments = defaultSkin.obj(slotName)
?: defaultSkin.obj("attachments")?.obj(slotName)
?: JsonObject()
return attachments.map { it.key }
}

Expand Down Expand Up @@ -142,8 +149,11 @@ class SpineJson(private val filePath: Path) {
animationNames.add(animationName)
}

override fun toString(): String {
return json.toJsonString(prettyPrint = true)
}

fun save() {
var string = json.toJsonString(prettyPrint = true)
Files.write(filePath, listOf(string), StandardCharsets.UTF_8)
Files.write(filePath, listOf(toString()), StandardCharsets.UTF_8)
}
}
Empty file.
Empty file.
Loading

0 comments on commit e57fc97

Please sign in to comment.